You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(23) |
Apr
(254) |
May
(252) |
Jun
(209) |
Jul
(198) |
Aug
(192) |
Sep
(207) |
Oct
(120) |
Nov
(179) |
Dec
(52) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(48) |
Feb
(69) |
Mar
(129) |
Apr
(250) |
May
(113) |
Jun
(177) |
Jul
(228) |
Aug
(155) |
Sep
(218) |
Oct
(185) |
Nov
(109) |
Dec
(88) |
2009 |
Jan
(83) |
Feb
(39) |
Mar
(70) |
Apr
(47) |
May
(48) |
Jun
(67) |
Jul
(61) |
Aug
(97) |
Sep
(221) |
Oct
(141) |
Nov
(70) |
Dec
(61) |
2010 |
Jan
(45) |
Feb
(76) |
Mar
(178) |
Apr
(106) |
May
(57) |
Jun
(32) |
Jul
(64) |
Aug
(98) |
Sep
(96) |
Oct
(19) |
Nov
(34) |
Dec
(117) |
2011 |
Jan
(55) |
Feb
(48) |
Mar
(64) |
Apr
(21) |
May
(39) |
Jun
(53) |
Jul
(99) |
Aug
(56) |
Sep
(39) |
Oct
(26) |
Nov
(19) |
Dec
(69) |
2012 |
Jan
(17) |
Feb
(40) |
Mar
(17) |
Apr
|
May
(2) |
Jun
(8) |
Jul
(2) |
Aug
(10) |
Sep
(10) |
Oct
(38) |
Nov
(48) |
Dec
(70) |
2013 |
Jan
(43) |
Feb
(47) |
Mar
(39) |
Apr
(37) |
May
(25) |
Jun
(6) |
Jul
(20) |
Aug
(49) |
Sep
(33) |
Oct
(34) |
Nov
(75) |
Dec
(6) |
2014 |
Jan
(32) |
Feb
(10) |
Mar
(17) |
Apr
|
May
|
Jun
(26) |
Jul
(5) |
Aug
|
Sep
(4) |
Oct
(23) |
Nov
(80) |
Dec
(48) |
2015 |
Jan
(80) |
Feb
(50) |
Mar
(58) |
Apr
(20) |
May
(11) |
Jun
(16) |
Jul
(24) |
Aug
(27) |
Sep
(56) |
Oct
(30) |
Nov
(16) |
Dec
(6) |
2016 |
Jan
(31) |
Feb
(14) |
Mar
(23) |
Apr
(17) |
May
(40) |
Jun
(12) |
Jul
(17) |
Aug
(9) |
Sep
(32) |
Oct
(36) |
Nov
(23) |
Dec
(9) |
2017 |
Jan
(37) |
Feb
(23) |
Mar
(65) |
Apr
(22) |
May
(6) |
Jun
(3) |
Jul
|
Aug
|
Sep
(3) |
Oct
(22) |
Nov
(63) |
Dec
(71) |
2018 |
Jan
(83) |
Feb
(21) |
Mar
(35) |
Apr
(44) |
May
(14) |
Jun
(12) |
Jul
(8) |
Aug
(18) |
Sep
(10) |
Oct
(145) |
Nov
(144) |
Dec
(76) |
2019 |
Jan
(18) |
Feb
(28) |
Mar
(5) |
Apr
(208) |
May
(291) |
Jun
(158) |
Jul
(27) |
Aug
(8) |
Sep
(10) |
Oct
(83) |
Nov
(41) |
Dec
(31) |
2020 |
Jan
(16) |
Feb
(46) |
Mar
(100) |
Apr
(78) |
May
(69) |
Jun
(71) |
Jul
(28) |
Aug
(131) |
Sep
(176) |
Oct
(89) |
Nov
(147) |
Dec
(19) |
2021 |
Jan
(19) |
Feb
(25) |
Mar
(91) |
Apr
(98) |
May
(14) |
Jun
(44) |
Jul
(8) |
Aug
(3) |
Sep
(38) |
Oct
(57) |
Nov
(97) |
Dec
(74) |
2022 |
Jan
(89) |
Feb
(47) |
Mar
(15) |
Apr
(50) |
May
(54) |
Jun
(56) |
Jul
(80) |
Aug
(12) |
Sep
(11) |
Oct
(60) |
Nov
(48) |
Dec
(4) |
2023 |
Jan
(75) |
Feb
(49) |
Mar
(84) |
Apr
(24) |
May
(13) |
Jun
(74) |
Jul
(32) |
Aug
(66) |
Sep
(50) |
Oct
(38) |
Nov
(105) |
Dec
(181) |
2024 |
Jan
(21) |
Feb
(49) |
Mar
(77) |
Apr
(84) |
May
(20) |
Jun
(71) |
Jul
(53) |
Aug
(33) |
Sep
(54) |
Oct
(124) |
Nov
(151) |
Dec
(73) |
2025 |
Jan
(61) |
Feb
(17) |
Mar
(136) |
Apr
(72) |
May
(200) |
Jun
(238) |
Jul
(91) |
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
From: <ho...@us...> - 2007-05-22 17:35:14
|
Revision: 2108 http://skim-app.svn.sourceforge.net/skim-app/?rev=2108&view=rev Author: hofman Date: 2007-05-22 10:34:56 -0700 (Tue, 22 May 2007) Log Message: ----------- Revert document when it has changed on disk. Apple's implementation does nothing when there are no unsaved changes. Modified Paths: -------------- trunk/Dutch.lproj/Localizable.strings trunk/English.lproj/Localizable.strings trunk/Italian.lproj/Localizable.strings trunk/SKDocument.h trunk/SKDocument.m Modified: trunk/Dutch.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/English.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/SKDocument.h =================================================================== --- trunk/SKDocument.h 2007-05-22 16:49:46 UTC (rev 2107) +++ trunk/SKDocument.h 2007-05-22 17:34:56 UTC (rev 2108) @@ -64,6 +64,7 @@ NSDate *previousCheckedDate; BOOL autoUpdate; int numberOfTries; + BOOL fileChangedOnDisk; } - (IBAction)readNotes:(id)sender; Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-05-22 16:49:46 UTC (rev 2107) +++ trunk/SKDocument.m 2007-05-22 17:34:56 UTC (rev 2108) @@ -168,6 +168,7 @@ [[self undoManager] removeAllActions]; [self updateChangeCount:NSChangeCleared]; [self setLastChangedDate:[[fm fileAttributesAtPath:[absoluteURL path] traverseLink:YES] fileModificationDate]]; + fileChangedOnDisk = NO; } } @@ -270,6 +271,7 @@ didRead = YES; [self setLastChangedDate:nil]; [self updateChangeCount:NSChangeDone]; + fileChangedOnDisk = NO; } if (didRead == NO && outError != NULL) @@ -278,7 +280,7 @@ return didRead; } -- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)docType error:(NSError **)outError{log_method(); +- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)docType error:(NSError **)outError{ BOOL didRead = NO; NSData *data = nil; PDFDocument *pdfDoc = nil; @@ -339,6 +341,7 @@ [pdfDoc release]; [data release]; [self setLastChangedDate:[[[NSFileManager defaultManager] fileAttributesAtPath:[absoluteURL path] traverseLink:YES] fileModificationDate]]; + fileChangedOnDisk = NO; } else { [self setPDFData:nil]; } @@ -490,6 +493,59 @@ } } +- (void)revertAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { + if (returnCode == NSAlertDefaultReturn) { + NSError *error = nil; + if (NO == [self revertToContentsOfURL:[self fileURL] ofType:[self fileType] error:&error]) { + [[alert window] orderOut:nil]; + [self presentError:error modalForWindow:[[self mainWindowController] window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; + } + } +} + +- (void)revertDocumentToSaved:(id)sender { + if ([self fileName]) { + if ([self isDocumentEdited]) { + [super revertDocumentToSaved:sender]; + } else { + BOOL shouldRevert = fileChangedOnDisk; + if (shouldRevert == NO) { + NSDate *fileChangedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:[self fileName] traverseLink:YES] fileModificationDate]; + shouldRevert = [lastChangedDate compare:fileChangedDate] == NSOrderedAscending; + } + if (shouldRevert) { + NSAlert *alert = [NSAlert alertWithMessageText:[NSString stringWithFormat:NSLocalizedString(@"Do you want to revert to the version of the document \"%@\" on disk?", @"Message in alert dialog"), [[self fileName] lastPathComponent]] + defaultButton:NSLocalizedString(@"Revert", @"Button title") + alternateButton:NSLocalizedString(@"Cancel", @"Button title") + otherButton:nil + informativeTextWithFormat:NSLocalizedString(@"Your current changes will be lost.", @"Informative text in alert dialog")]; + [alert beginSheetModalForWindow:[[self mainWindowController] window] + modalDelegate:self + didEndSelector:@selector(revertAlertDidEnd:returnCode:contextInfo:) + contextInfo:NULL]; + } + } + } +} + +- (void)performFindPanelAction:(id)sender { + [[SKFindController sharedFindController] performFindPanelAction:sender]; +} + +- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { + if ([anItem action] == @selector(performFindPanelAction:)) { + return [[SKFindController sharedFindController] validateUserInterfaceItem:anItem]; + } else if ([anItem action] == @selector(revertDocumentToSaved:)) { + if ([self fileName] == nil) + return NO; + if ([self isDocumentEdited] || fileChangedOnDisk) + return YES; + NSDate *fileChangedDate = [[[NSFileManager defaultManager] fileAttributesAtPath:[self fileName] traverseLink:YES] fileModificationDate]; + return [lastChangedDate compare:fileChangedDate] == NSOrderedAscending; + } else + return [super validateUserInterfaceItem:anItem]; +} + #pragma mark File update checking // For now this just uses a timer checking the modification date of the file. We may want to use kqueue (UKKqueue) at some point. @@ -542,6 +598,7 @@ NSDate *fileChangedDate = [[fm fileAttributesAtPath:[self fileName] traverseLink:YES] fileModificationDate]; if ([lastChangedDate compare:fileChangedDate] == NSOrderedAscending) { + fileChangedOnDisk = YES; // check until the data stabilizes, because a (tex) process may be busy writing to the file if (previousCheckedDate && [previousCheckedDate compare:fileChangedDate] == NSOrderedSame) { if (autoUpdate && [self isDocumentEdited] == NO) { @@ -690,17 +747,6 @@ return setup; } -- (void)performFindPanelAction:(id)sender { - [[SKFindController sharedFindController] performFindPanelAction:sender]; -} - -- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { - if ([anItem action] == @selector(performFindPanelAction:)) - return [[SKFindController sharedFindController] validateUserInterfaceItem:anItem]; - else - return [super validateUserInterfaceItem:anItem]; -} - - (void)findString:(NSString *)string options:(int)options{ [[self mainWindowController] findString:string options:options]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 16:49:50
|
Revision: 2107 http://skim-app.svn.sourceforge.net/skim-app/?rev=2107&view=rev Author: hofman Date: 2007-05-22 09:49:46 -0700 (Tue, 22 May 2007) Log Message: ----------- Always warn when reloading failed and we were not automatically reloading. Don't disable Revert menu item, as the file might also be changed on disk. Modified Paths: -------------- trunk/SKDocument.m Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-05-22 15:40:46 UTC (rev 2106) +++ trunk/SKDocument.m 2007-05-22 16:49:46 UTC (rev 2107) @@ -278,7 +278,7 @@ return didRead; } -- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)docType error:(NSError **)outError{ +- (BOOL)readFromURL:(NSURL *)absoluteURL ofType:(NSString *)docType error:(NSError **)outError{log_method(); BOOL didRead = NO; NSData *data = nil; PDFDocument *pdfDoc = nil; @@ -517,7 +517,7 @@ } else { NSError *error = nil; if (NO == [self revertToContentsOfURL:[self fileURL] ofType:[self fileType] error:&error]) { - if (autoUpdate && ++numberOfTries > 10) { + if (autoUpdate == NO || ++numberOfTries > 10) { [[alert window] orderOut:nil]; [self presentError:error modalForWindow:[[self mainWindowController] window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; [self setLastChangedDate:changeDate]; @@ -697,8 +697,6 @@ - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { if ([anItem action] == @selector(performFindPanelAction:)) return [[SKFindController sharedFindController] validateUserInterfaceItem:anItem]; - else if ([anItem action] == @selector(revertDocumentToSaved:)) - return [self isDocumentEdited]; else return [super validateUserInterfaceItem:anItem]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 15:40:47
|
Revision: 2106 http://skim-app.svn.sourceforge.net/skim-app/?rev=2106&view=rev Author: hofman Date: 2007-05-22 08:40:46 -0700 (Tue, 22 May 2007) Log Message: ----------- Retry 10x auto-reloading file, because latex might be very slow for large files. Modified Paths: -------------- trunk/SKDocument.h trunk/SKDocument.m Modified: trunk/SKDocument.h =================================================================== --- trunk/SKDocument.h 2007-05-22 14:41:00 UTC (rev 2105) +++ trunk/SKDocument.h 2007-05-22 15:40:46 UTC (rev 2106) @@ -63,6 +63,7 @@ NSDate *lastChangedDate; NSDate *previousCheckedDate; BOOL autoUpdate; + int numberOfTries; } - (IBAction)readNotes:(id)sender; Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-05-22 14:41:00 UTC (rev 2105) +++ trunk/SKDocument.m 2007-05-22 15:40:46 UTC (rev 2106) @@ -333,6 +333,7 @@ if (data) { if (pdfDoc) { didRead = YES; + numberOfTries = 0; [self setPDFData:data]; [self setPDFDoc:pdfDoc]; [pdfDoc release]; @@ -516,9 +517,11 @@ } else { NSError *error = nil; if (NO == [self revertToContentsOfURL:[self fileURL] ofType:[self fileType] error:&error]) { - [[alert window] orderOut:nil]; - [self presentError:error modalForWindow:[[self mainWindowController] window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; - [self setLastChangedDate:changeDate]; + if (autoUpdate && ++numberOfTries > 10) { + [[alert window] orderOut:nil]; + [self presentError:error modalForWindow:[[self mainWindowController] window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; + [self setLastChangedDate:changeDate]; + } } if (returnCode == NSAlertAlternateReturn) autoUpdate = YES; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 14:41:03
|
Revision: 2105 http://skim-app.svn.sourceforge.net/skim-app/?rev=2105&view=rev Author: hofman Date: 2007-05-22 07:41:00 -0700 (Tue, 22 May 2007) Log Message: ----------- Revert an earlier commit. Don't check for file updates too soon, as latex doesn't seem to write continuously. Show alert for failed reload as a sheet. Modified Paths: -------------- trunk/SKDocument.m Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-05-22 13:00:01 UTC (rev 2104) +++ trunk/SKDocument.m 2007-05-22 14:41:00 UTC (rev 2105) @@ -493,7 +493,7 @@ // For now this just uses a timer checking the modification date of the file. We may want to use kqueue (UKKqueue) at some point. -- (void)checkFileUpdatesIfNeededAfterDelay:(NSTimeInterval)delay { +- (void)checkFileUpdatesIfNeeded { BOOL autoUpdatePref = [[NSUserDefaults standardUserDefaults] boolForKey:SKAutoCheckFileUpdateKey]; if (autoUpdatePref == NO && fileUpdateTimer) { @@ -502,15 +502,11 @@ fileUpdateTimer = nil; autoUpdate = NO; } else if (autoUpdatePref && fileUpdateTimer == nil) { - fileUpdateTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:delay] interval:0.0 target:self selector:@selector(checkFileUpdateStatus:) userInfo:NULL repeats:NO]; + fileUpdateTimer = [[NSTimer alloc] initWithFireDate:[NSDate dateWithTimeIntervalSinceNow:2.0] interval:0.0 target:self selector:@selector(checkFileUpdateStatus:) userInfo:NULL repeats:NO]; [[NSRunLoop currentRunLoop] addTimer:fileUpdateTimer forMode:NSDefaultRunLoopMode]; } } -- (void)checkFileUpdatesIfNeeded { - [self checkFileUpdatesIfNeededAfterDelay:2.0]; -} - - (void)fileUpdateAlertDidEnd:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { NSDate *changeDate = (NSDate *)contextInfo; @@ -520,7 +516,8 @@ } else { NSError *error = nil; if (NO == [self revertToContentsOfURL:[self fileURL] ofType:[self fileType] error:&error]) { - [self presentError:error]; + [[alert window] orderOut:nil]; + [self presentError:error modalForWindow:[[self mainWindowController] window] delegate:nil didPresentSelector:NULL contextInfo:NULL]; [self setLastChangedDate:changeDate]; } if (returnCode == NSAlertAlternateReturn) @@ -535,7 +532,6 @@ fileUpdateTimer = nil; NSFileManager *fm = [NSFileManager defaultManager]; - NSTimeInterval delay = 2.0; if ([[NSUserDefaults standardUserDefaults] boolForKey:SKAutoCheckFileUpdateKey] && [fm fileExistsAtPath:[self fileName]]) { @@ -569,12 +565,11 @@ } else { [previousCheckedDate release]; previousCheckedDate = [fileChangedDate retain]; - delay = 0.5; } } } - [self checkFileUpdatesIfNeededAfterDelay:delay]; + [self checkFileUpdatesIfNeeded]; } #pragma mark Notification observation This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 13:00:05
|
Revision: 2104 http://skim-app.svn.sourceforge.net/skim-app/?rev=2104&view=rev Author: hofman Date: 2007-05-22 06:00:01 -0700 (Tue, 22 May 2007) Log Message: ----------- Better redisplay of selection. Don't check zero selectionRect, as that may need redisplay when dragging. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-22 11:46:36 UTC (rev 2103) +++ trunk/SKPDFView.m 2007-05-22 13:00:01 UTC (rev 2104) @@ -325,7 +325,7 @@ float color[4] = { 0.0, 0.0, 0.0, 1.0 }; CGContextSetStrokeColor(context, color); CGContextStrokeRect(context, *(CGRect *)&rect); - } else if (toolMode == SKSelectToolMode && NSEqualRects(selectionRect, NSZeroRect) == NO) { + } else if (toolMode == SKSelectToolMode && (didDrag || NSEqualRects(selectionRect, NSZeroRect) == NO)) { NSRect bounds = [pdfPage boundsForBox:[self displayBox]]; float color[4] = { 0.0, 0.0, 0.0, 0.6 }; float radius = 4.0 / [self scaleFactor]; @@ -2541,13 +2541,14 @@ NSPoint initialPoint = [self convertPoint:mouseLoc toPage:page]; float margin = 4.0 / [self scaleFactor]; int xEdge = 0, yEdge = 0; - BOOL needsDisplay = NO; if (NSIsEmptyRect(selectionRect) || NSPointInRect(initialPoint, NSInsetRect(selectionRect, -margin, -margin)) == NO) { - if (NSEqualRects(selectionRect, NSZeroRect)) - needsDisplay = YES; - else + if (NSIsEmptyRect(selectionRect)) { + didDrag = NO; + } else { [self setNeedsDisplay:YES]; + didDrag = YES; + } selectionRect.origin = initialPoint; selectionRect.size = NSZeroSize; xEdge = 1; @@ -2561,6 +2562,7 @@ yEdge = 1; else if (initialPoint.y < NSMinY(selectionRect) + margin) yEdge = 2; + didDrag = YES; } NSRect initialRect = selectionRect; @@ -2627,24 +2629,22 @@ float minY = fmin(fmax(NSMinY(newRect), NSMinY(pageBounds)), NSMaxY(pageBounds)); float maxY = fmax(fmin(NSMaxY(newRect), NSMaxY(pageBounds)), NSMinY(pageBounds)); newRect = NSMakeRect(minX, minY, maxX - minX, maxY - minY); - if (needsDisplay) { + if (didDrag) { + NSRect dirtyRect = NSUnionRect(NSInsetRect(selectionRect, -margin, -margin), NSInsetRect(newRect, -margin, -margin)); + NSRange r = [self visiblePageIndexRange]; + unsigned int i; + for (i = r.location; i < NSMaxRange(r); i++) + [self setNeedsDisplayInRect:dirtyRect ofPage:[[self document] pageAtIndex:i]]; + } else { [self setNeedsDisplay:YES]; - needsDisplay = NO; - } else { - NSRect dirtyRect = NSEqualRects(selectionRect, NSZeroRect) ? NSZeroRect : NSInsetRect(selectionRect, -margin, -margin); - if (NSEqualRects(newRect, NSZeroRect) == NO) - dirtyRect = NSUnionRect(dirtyRect, NSInsetRect(newRect, -margin, -margin)); - if (NSIsEmptyRect(dirtyRect) == NO) { - NSRange r = [self visiblePageIndexRange]; - unsigned int i; - for (i = r.location; i < NSMaxRange(r); i++) - [self setNeedsDisplayInRect:dirtyRect ofPage:[[self document] pageAtIndex:i]]; - } + didDrag = YES; } selectionRect = newRect; } + didDrag = NO; + if (NSIsEmptyRect(selectionRect)) { selectionRect = NSZeroRect; [self setNeedsDisplay:YES]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 11:46:39
|
Revision: 2103 http://skim-app.svn.sourceforge.net/skim-app/?rev=2103&view=rev Author: hofman Date: 2007-05-22 04:46:36 -0700 (Tue, 22 May 2007) Log Message: ----------- Only redisplay rects for selection modifications. Modified Paths: -------------- trunk/SKPDFView.h trunk/SKPDFView.m Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2007-05-22 10:08:36 UTC (rev 2102) +++ trunk/SKPDFView.h 2007-05-22 11:46:36 UTC (rev 2103) @@ -86,7 +86,6 @@ PDFAnnotation *activeAnnotation; PDFAnnotationTextWidget *editAnnotation; PDFSelection *wasSelection; - PDFPage *activePage; NSRect wasBounds; NSPoint wasStartPoint; NSPoint wasEndPoint; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-22 10:08:36 UTC (rev 2102) +++ trunk/SKPDFView.m 2007-05-22 11:46:36 UTC (rev 2103) @@ -157,13 +157,22 @@ readingBar = nil; activeAnnotation = nil; - editAnnotation = NO; + editAnnotation = nil; + wasSelection = nil; wasBounds = NSZeroRect; + wasStartPoint = NSZeroPoint; + wasEndPoint = NSZeroPoint; mouseDownLoc = NSZeroPoint; clickDelta = NSZeroPoint; + selectionRect = NSZeroRect; resizingAnnotation = NO; draggingAnnotation = NO; + draggingStartPoint = NO; + didDrag = NO; + didBeginUndoGrouping = NO; mouseDownInAnnotation = NO; + extendSelection = NO; + rectSelection = NO; trackingRect = 0; @@ -311,12 +320,12 @@ } } - if (NSIsEmptyRect(selectionRect) == NO && toolMode != SKSelectToolMode) { + if (toolMode != SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { NSRect rect = NSInsetRect([self convertRect:selectionRect toPage:pdfPage], 0.5, 0.5); float color[4] = { 0.0, 0.0, 0.0, 1.0 }; CGContextSetStrokeColor(context, color); CGContextStrokeRect(context, *(CGRect *)&rect); - } else if (toolMode == SKSelectToolMode && activePage) { + } else if (toolMode == SKSelectToolMode && NSEqualRects(selectionRect, NSZeroRect) == NO) { NSRect bounds = [pdfPage boundsForBox:[self displayBox]]; float color[4] = { 0.0, 0.0, 0.0, 0.6 }; float radius = 4.0 / [self scaleFactor]; @@ -325,21 +334,14 @@ CGContextAddRect(context, *(CGRect *)&selectionRect); CGContextSetFillColor(context, color); CGContextEOFillPath(context); - if ([activePage isEqual:pdfPage] == NO) { - color[3] = 0.4; - CGContextSetFillColor(context, color); - CGContextFillRect(context, *(CGRect *)&selectionRect); - } - if ([activePage isEqual:pdfPage] && NSEqualRects(selectionRect, NSZeroRect) == NO) { - SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMinY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMaxY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMinY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMaxY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMidY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMidY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMidX(selectionRect), NSMinY(selectionRect)), radius); - SKCGContextDrawGrabHandle(context, CGPointMake(NSMidX(selectionRect), NSMaxY(selectionRect)), radius); - } + SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMinY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMaxY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMinY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMaxY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMidY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMaxX(selectionRect), NSMidY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMidX(selectionRect), NSMinY(selectionRect)), radius); + SKCGContextDrawGrabHandle(context, CGPointMake(NSMidX(selectionRect), NSMaxY(selectionRect)), radius); } CGContextRestoreGState(context); @@ -375,7 +377,6 @@ - (void)setDocument:(PDFDocument *)document { [readingBar release]; readingBar = nil; - activePage = nil; selectionRect = NSZeroRect; [self removeHoverRects]; [super setDocument:document]; @@ -395,8 +396,7 @@ [self setActiveAnnotation:nil]; if ([self currentSelection]) [self setCurrentSelection:nil]; - } else if (toolMode == SKSelectToolMode && activePage) { - activePage = nil; + } else if (toolMode == SKSelectToolMode && NSEqualRects(selectionRect, NSZeroRect) == NO) { selectionRect = NSZeroRect; [self setNeedsDisplay:YES]; } @@ -451,7 +451,7 @@ } - (NSRect)currentSelectionRect { - if (toolMode == SKSelectToolMode || activePage) + if (toolMode == SKSelectToolMode) return selectionRect; return NSZeroRect; } @@ -500,10 +500,10 @@ [types addObject:SKSkimNotePboardType]; } - if (toolMode == SKSelectToolMode && activePage) { - PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[activePage dataRepresentation]]; + if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { + PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[[self currentPage] dataRepresentation]]; PDFPage *page = [pdfDoc pageAtIndex:0]; - [page setBounds:[activePage boundsForBox:kPDFDisplayBoxMediaBox] forBox:kPDFDisplayBoxMediaBox]; + [page setBounds:[[self currentPage] boundsForBox:kPDFDisplayBoxMediaBox] forBox:kPDFDisplayBoxMediaBox]; [page setBounds:selectionRect forBox:kPDFDisplayBoxCropBox]; [page setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox]; [page setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox]; @@ -513,9 +513,9 @@ [types addObject:NSPDFPboardType]; [pdfDoc release]; - NSRect bounds = [activePage boundsForBox:[self displayBox]]; + NSRect bounds = [[self currentPage] boundsForBox:[self displayBox]]; NSRect targetRect = NSZeroRect, sourceRect = selectionRect; - NSImage *pageImage = [activePage imageForBox:[self displayBox]]; + NSImage *pageImage = [[self currentPage] imageForBox:[self displayBox]]; NSImage *image = nil; sourceRect.origin.x -= NSMinX(bounds); @@ -532,7 +532,7 @@ /* Possible hidden default? Alternate way of getting a bitmap rep; this varies resolution with zoom level, which is very useful if you want to copy a single figure or equation for a non-PDF-capable program. The first copy: action has some odd behavior, though (view moves). Preview produces a fixed resolution bitmap for a given selection area regardless of zoom. - sourceRect = [self convertRect:selectionRect fromPage:activePage]; + sourceRect = [self convertRect:selectionRect fromPage:[self currentPage]]; NSBitmapImageRep *imageRep = [self bitmapImageRepForCachingDisplayInRect:sourceRect]; [self cacheDisplayInRect:sourceRect toBitmapImageRep:imageRep]; tiffData = [imageRep TIFFRepresentation]; @@ -1052,7 +1052,7 @@ if ([[menu itemAtIndex:0] isSeparatorItem]) [menu removeItemAtIndex:0]; - } else if (toolMode == SKSelectToolMode && activePage) { + } else if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { [menu insertItem:[NSMenuItem separatorItem] atIndex:0]; @@ -1521,9 +1521,9 @@ PDFPage *page = nil; NSRect rect = NSZeroRect; - if (toolMode == SKSelectToolMode && activePage) { - rect = NSIntersectionRect(selectionRect, [activePage boundsForBox:kPDFDisplayBoxCropBox]); - page = activePage; + if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) { + rect = NSIntersectionRect(selectionRect, [[self currentPage] boundsForBox:kPDFDisplayBoxCropBox]); + page = [self currentPage]; } if (NSIsEmptyRect(rect)) { if ([sender respondsToSelector:@selector(representedObject)] && [[sender representedObject] respondsToSelector:@selector(pointValue)]) { @@ -1614,7 +1614,7 @@ return YES; if ([activeAnnotation isNoteAnnotation] && [activeAnnotation isMovable]) return YES; - if (toolMode == SKSelectToolMode && activePage) + if (toolMode == SKSelectToolMode && NSIsEmptyRect(selectionRect) == NO) return YES; return NO; } else { @@ -2533,7 +2533,6 @@ PDFPage *page = [self pageForPoint:mouseLoc nearest:NO]; if (page == nil) { - activePage = nil; selectionRect = NSZeroRect; [self setNeedsDisplay:YES]; return; @@ -2544,12 +2543,11 @@ int xEdge = 0, yEdge = 0; BOOL needsDisplay = NO; - if ([page isEqual:activePage] == NO || NSPointInRect(initialPoint, NSInsetRect(selectionRect, -margin, -margin)) == NO) { - if (activePage) + if (NSIsEmptyRect(selectionRect) || NSPointInRect(initialPoint, NSInsetRect(selectionRect, -margin, -margin)) == NO) { + if (NSEqualRects(selectionRect, NSZeroRect)) + needsDisplay = YES; + else [self setNeedsDisplay:YES]; - else - needsDisplay = YES; - activePage = page; selectionRect.origin = initialPoint; selectionRect.size = NSZeroSize; xEdge = 1; @@ -2566,7 +2564,7 @@ } NSRect initialRect = selectionRect; - NSRect pageBounds = [activePage boundsForBox:[self displayBox]]; + NSRect pageBounds = [page boundsForBox:[self displayBox]]; if (xEdge == 0 && yEdge == 0) [[NSCursor closedHandCursor] push]; @@ -2623,23 +2621,31 @@ } } - if (NSMinX(newRect) < NSMinX(pageBounds) || NSMaxX(newRect) > NSMaxX(pageBounds) || NSMinY(newRect) < NSMinY(pageBounds) || NSMaxY(newRect) > NSMaxY(pageBounds)) - newRect = NSIntersectionRect(newRect, pageBounds); - //if (needsDisplay) { + // don't use NSIntersectionRect, because we want to keep empty rects + float minX = fmin(fmax(NSMinX(newRect), NSMinX(pageBounds)), NSMaxX(pageBounds)); + float maxX = fmax(fmin(NSMaxX(newRect), NSMaxX(pageBounds)), NSMinX(pageBounds)); + float minY = fmin(fmax(NSMinY(newRect), NSMinY(pageBounds)), NSMaxY(pageBounds)); + float maxY = fmax(fmin(NSMaxY(newRect), NSMaxY(pageBounds)), NSMinY(pageBounds)); + newRect = NSMakeRect(minX, minY, maxX - minX, maxY - minY); + if (needsDisplay) { [self setNeedsDisplay:YES]; needsDisplay = NO; - //} else { - // if (NSEqualRects(selectionRect, NSZeroRect) == NO) - // [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin, -margin) ofPage:activePage]; - // if (NSEqualRects(newRect, NSZeroRect) == NO) - // [self setNeedsDisplayInRect:NSInsetRect(newRect, -margin, -margin) ofPage:activePage]; - //} + } else { + NSRect dirtyRect = NSEqualRects(selectionRect, NSZeroRect) ? NSZeroRect : NSInsetRect(selectionRect, -margin, -margin); + if (NSEqualRects(newRect, NSZeroRect) == NO) + dirtyRect = NSUnionRect(dirtyRect, NSInsetRect(newRect, -margin, -margin)); + if (NSIsEmptyRect(dirtyRect) == NO) { + NSRange r = [self visiblePageIndexRange]; + unsigned int i; + for (i = r.location; i < NSMaxRange(r); i++) + [self setNeedsDisplayInRect:dirtyRect ofPage:[[self document] pageAtIndex:i]]; + } + } selectionRect = newRect; } if (NSIsEmptyRect(selectionRect)) { - activePage = nil; selectionRect = NSZeroRect; [self setNeedsDisplay:YES]; } @@ -3041,7 +3047,7 @@ float margin = 4.0 / [self scaleFactor]; PDFPage *page = [self pageForPoint:p nearest:NO]; p = [self convertPoint:p toPage:page]; - if ([page isEqual:activePage] == NO || NSPointInRect(p, NSInsetRect(selectionRect, -margin, -margin)) == NO) + if (NSPointInRect(p, NSInsetRect(selectionRect, -margin, -margin)) == NO) cursor = [NSCursor crosshairCursor]; else if (NSPointInRect(p, NSInsetRect(selectionRect, margin, margin))) cursor = [NSCursor openHandCursor]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 10:08:42
|
Revision: 2102 http://skim-app.svn.sourceforge.net/skim-app/?rev=2102&view=rev Author: hofman Date: 2007-05-22 03:08:36 -0700 (Tue, 22 May 2007) Log Message: ----------- Make page rotation and crop undoable. Don't change the document change count, as this is not persistent. Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-22 09:22:06 UTC (rev 2101) +++ trunk/SKMainWindowController.m 2007-05-22 10:08:36 UTC (rev 2102) @@ -903,37 +903,39 @@ [self doAutoScale:sender]; } -- (IBAction)rotateRight:(id)sender { - [[pdfView currentPage] setRotation:[[pdfView currentPage] rotation] + 90]; +- (void)rotatePageAtIndex:(unsigned int)index by:(int)rotation { + NSUndoManager *undoManager = [[self document] undoManager]; + [[undoManager prepareWithInvocationTarget:self] rotatePageAtIndex:index by:-rotation]; + [[self document] updateChangeCount:[undoManager isUndoing] ? NSChangeDone : NSChangeUndone]; + + PDFPage *page = [[pdfView document] pageAtIndex:index]; + [page setRotation:[page rotation] + rotation]; [pdfView layoutDocumentView]; NSEnumerator *snapshotEnum = [snapshots objectEnumerator]; SKSnapshotWindowController *wc; while (wc = [snapshotEnum nextObject]) { - if ([wc isPageVisible:[pdfView currentPage]]) { + if ([wc isPageVisible:page]) { [self snapshotNeedsUpdate:wc]; [wc redisplay]; } } - [self updateThumbnailAtPageIndex:[[pdfView document] indexForPage:[pdfView currentPage]]]; + [self updateThumbnailAtPageIndex:index]; } +- (IBAction)rotateRight:(id)sender { + [self rotatePageAtIndex:[[pdfView document] indexForPage:[pdfView currentPage]] by:90]; +} + - (IBAction)rotateLeft:(id)sender { - [[pdfView currentPage] setRotation:[[pdfView currentPage] rotation] - 90]; - [pdfView layoutDocumentView]; - - NSEnumerator *snapshotEnum = [snapshots objectEnumerator]; - SKSnapshotWindowController *wc; - while (wc = [snapshotEnum nextObject]) { - if ([wc isPageVisible:[pdfView currentPage]]) { - [self snapshotNeedsUpdate:wc]; - [wc redisplay]; - } - } - [self updateThumbnailAtPageIndex:[[pdfView document] indexForPage:[pdfView currentPage]]]; + [self rotatePageAtIndex:[[pdfView document] indexForPage:[pdfView currentPage]] by:-90]; } - (IBAction)rotateAllRight:(id)sender { + NSUndoManager *undoManager = [[self document] undoManager]; + [[undoManager prepareWithInvocationTarget:self] rotateAllLeft:nil]; + [[self document] updateChangeCount:[undoManager isUndoing] ? NSChangeDone : NSChangeUndone]; + int i, count = [[pdfView document] pageCount]; for (i = 0 ; i < count; ++ i ) { [[[pdfView document] pageAtIndex:i] setRotation:[[[pdfView document] pageAtIndex:i] rotation] + 90]; @@ -947,6 +949,10 @@ } - (IBAction)rotateAllLeft:(id)sender { + NSUndoManager *undoManager = [[self document] undoManager]; + [[undoManager prepareWithInvocationTarget:self] rotateAllRight:nil]; + [[self document] updateChangeCount:[undoManager isUndoing] ? NSChangeDone : NSChangeUndone]; + int i, count = [[pdfView document] pageCount]; for (i = 0 ; i < count; ++ i ) { [[[pdfView document] pageAtIndex:i] setRotation:[[[pdfView document] pageAtIndex:i] rotation] - 90]; @@ -959,34 +965,50 @@ [self allThumbnailsNeedUpdate]; } -- (IBAction)crop:(id)sender { - NSRect selRect = [pdfView currentSelectionRect]; - if (NSIsEmptyRect(selRect)) - return; +- (void)cropPageAtIndex:(unsigned int)index toRect:(NSRect)rect { + NSRect oldRect = [[[pdfView document] pageAtIndex:index] boundsForBox:kPDFDisplayBoxCropBox]; + NSUndoManager *undoManager = [[self document] undoManager]; + [[undoManager prepareWithInvocationTarget:self] cropPageAtIndex:index toRect:oldRect]; + [[self document] updateChangeCount:[undoManager isUndoing] ? NSChangeDone : NSChangeUndone]; - [[pdfView currentPage] setBounds:selRect forBox:kPDFDisplayBoxCropBox]; + PDFPage *page = [[pdfView document] pageAtIndex:index]; + [page setBounds:rect forBox:kPDFDisplayBoxCropBox]; [pdfView layoutDocumentView]; NSEnumerator *snapshotEnum = [snapshots objectEnumerator]; SKSnapshotWindowController *wc; while (wc = [snapshotEnum nextObject]) { - if ([wc isPageVisible:[pdfView currentPage]]) { + if ([wc isPageVisible:page]) { [self snapshotNeedsUpdate:wc]; [wc redisplay]; } } - [self updateThumbnailAtPageIndex:[[pdfView document] indexForPage:[pdfView currentPage]]]; + [self updateThumbnailAtPageIndex:index]; } -- (IBAction)cropAll:(id)sender { +- (IBAction)crop:(id)sender { NSRect selRect = [pdfView currentSelectionRect]; if (NSIsEmptyRect(selRect)) return; + [self cropPageAtIndex:[[pdfView document] indexForPage:[pdfView currentPage]] toRect:selRect]; +} + +- (void)cropPagesToRects:(NSArray *)rects { + NSRect selRect = [pdfView currentSelectionRect]; int i, count = [[pdfView document] pageCount]; + NSMutableArray *oldRects = [NSMutableArray arrayWithCapacity:count]; for (i = 0 ; i < count; ++ i ) { - [[[pdfView document] pageAtIndex:i] setBounds:selRect forBox:kPDFDisplayBoxCropBox]; + PDFPage *page = [[pdfView document] pageAtIndex:i]; + NSRect rect = rects ? [[rects objectAtIndex:i] rectValue] : selRect; + [oldRects addObject:[NSValue valueWithRect:[page boundsForBox:kPDFDisplayBoxCropBox]]]; + [page setBounds:rect forBox:kPDFDisplayBoxCropBox]; } + + NSUndoManager *undoManager = [[self document] undoManager]; + [[undoManager prepareWithInvocationTarget:self] cropPagesToRects:oldRects]; + [[self document] updateChangeCount:[undoManager isUndoing] ? NSChangeDone : NSChangeUndone]; + [pdfView layoutDocumentView]; [snapshots makeObjectsPerformSelector:@selector(redisplay) withObject:nil]; @@ -995,6 +1017,14 @@ [self allThumbnailsNeedUpdate]; } +- (IBAction)cropAll:(id)sender { + NSRect selRect = [pdfView currentSelectionRect]; + if (NSIsEmptyRect(selRect)) + return; + + [self cropPagesToRects:nil]; +} + - (IBAction)getInfo:(id)sender { SKInfoWindowController *infoController = [SKInfoWindowController sharedInstance]; [infoController fillInfoForDocument:[self document]]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-22 09:22:09
|
Revision: 2101 http://skim-app.svn.sourceforge.net/skim-app/?rev=2101&view=rev Author: hofman Date: 2007-05-22 02:22:06 -0700 (Tue, 22 May 2007) Log Message: ----------- Add a crop action for selection mode. Accessible through main menu and toolbar button. Modified Paths: -------------- trunk/Dutch.lproj/Localizable.strings trunk/Dutch.lproj/MainMenu.nib/classes.nib trunk/Dutch.lproj/MainMenu.nib/keyedobjects.nib trunk/English.lproj/Localizable.strings trunk/English.lproj/MainMenu.nib/classes.nib trunk/English.lproj/MainMenu.nib/keyedobjects.nib trunk/Italian.lproj/Localizable.strings trunk/Italian.lproj/MainMenu.nib/classes.nib trunk/Italian.lproj/MainMenu.nib/keyedobjects.nib trunk/SKMainWindowController.h trunk/SKMainWindowController.m trunk/SKPDFView.h trunk/SKPDFView.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/Images/ToolbarCrop.tiff Modified: trunk/Dutch.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Dutch.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/Dutch.lproj/MainMenu.nib/classes.nib 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/Dutch.lproj/MainMenu.nib/classes.nib 2007-05-22 09:22:06 UTC (rev 2101) @@ -10,6 +10,8 @@ changeRightSidePaneState = id; changeToolMode = id; createNewNote = id; + crop = id; + cropAll = id; displayCropBox = id; displayFacingPages = id; displayMediaBox = id; Modified: trunk/Dutch.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/English.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/English.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/English.lproj/MainMenu.nib/classes.nib 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/English.lproj/MainMenu.nib/classes.nib 2007-05-22 09:22:06 UTC (rev 2101) @@ -10,6 +10,8 @@ changeRightSidePaneState = id; changeToolMode = id; createNewNote = id; + crop = id; + cropAll = id; displayCropBox = id; displayFacingPages = id; displayMediaBox = id; Modified: trunk/English.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Added: trunk/Images/ToolbarCrop.tiff =================================================================== (Binary files differ) Property changes on: trunk/Images/ToolbarCrop.tiff ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/Italian.lproj/Localizable.strings =================================================================== (Binary files differ) Modified: trunk/Italian.lproj/MainMenu.nib/classes.nib =================================================================== --- trunk/Italian.lproj/MainMenu.nib/classes.nib 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/Italian.lproj/MainMenu.nib/classes.nib 2007-05-22 09:22:06 UTC (rev 2101) @@ -10,6 +10,8 @@ changeRightSidePaneState = id; changeToolMode = id; createNewNote = id; + crop = id; + cropAll = id; displayCropBox = id; displayFacingPages = id; displayMediaBox = id; Modified: trunk/Italian.lproj/MainMenu.nib/keyedobjects.nib =================================================================== (Binary files differ) Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/SKMainWindowController.h 2007-05-22 09:22:06 UTC (rev 2101) @@ -201,6 +201,8 @@ - (IBAction)rotateLeft:(id)sender; - (IBAction)rotateAllRight:(id)sender; - (IBAction)rotateAllLeft:(id)sender; +- (IBAction)crop:(id)sender; +- (IBAction)cropAll:(id)sender; - (IBAction)getInfo:(id)sender; - (void)displaySearchResultsForString:(NSString *)string; - (IBAction)search:(id)sender; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/SKMainWindowController.m 2007-05-22 09:22:06 UTC (rev 2101) @@ -88,6 +88,7 @@ static NSString *SKDocumentToolbarZoomToFitItemIdentifier = @"SKDocumentZoomAutoToolbarItemIdentifier"; static NSString *SKDocumentToolbarRotateRightItemIdentifier = @"SKDocumentRotateRightToolbarItemIdentifier"; static NSString *SKDocumentToolbarRotateLeftItemIdentifier = @"SKDocumentRotateLeftToolbarItemIdentifier"; +static NSString *SKDocumentToolbarCropItemIdentifier = @"SKDocumentToolbarCropItemIdentifier"; static NSString *SKDocumentToolbarFullScreenItemIdentifier = @"SKDocumentFullScreenToolbarItemIdentifier"; static NSString *SKDocumentToolbarPresentationItemIdentifier = @"SKDocumentToolbarPresentationItemIdentifier"; static NSString *SKDocumentToolbarNewNoteItemIdentifier = @"SKDocumentToolbarNewNoteItemIdentifier"; @@ -958,6 +959,42 @@ [self allThumbnailsNeedUpdate]; } +- (IBAction)crop:(id)sender { + NSRect selRect = [pdfView currentSelectionRect]; + if (NSIsEmptyRect(selRect)) + return; + + [[pdfView currentPage] setBounds:selRect forBox:kPDFDisplayBoxCropBox]; + [pdfView layoutDocumentView]; + + NSEnumerator *snapshotEnum = [snapshots objectEnumerator]; + SKSnapshotWindowController *wc; + while (wc = [snapshotEnum nextObject]) { + if ([wc isPageVisible:[pdfView currentPage]]) { + [self snapshotNeedsUpdate:wc]; + [wc redisplay]; + } + } + [self updateThumbnailAtPageIndex:[[pdfView document] indexForPage:[pdfView currentPage]]]; +} + +- (IBAction)cropAll:(id)sender { + NSRect selRect = [pdfView currentSelectionRect]; + if (NSIsEmptyRect(selRect)) + return; + + int i, count = [[pdfView document] pageCount]; + for (i = 0 ; i < count; ++ i ) { + [[[pdfView document] pageAtIndex:i] setBounds:selRect forBox:kPDFDisplayBoxCropBox]; + } + [pdfView layoutDocumentView]; + + [snapshots makeObjectsPerformSelector:@selector(redisplay) withObject:nil]; + [self allSnapshotsNeedUpdate]; + + [self allThumbnailsNeedUpdate]; +} + - (IBAction)getInfo:(id)sender { SKInfoWindowController *infoController = [SKInfoWindowController sharedInstance]; [infoController fillInfoForDocument:[self document]]; @@ -2796,6 +2833,16 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarRotateLeftItemIdentifier]; [item release]; + item = [[SKToolbarItem alloc] initWithItemIdentifier:SKDocumentToolbarCropItemIdentifier]; + [item setLabel:NSLocalizedString(@"Crop", @"Toolbar item label")]; + [item setPaletteLabel:NSLocalizedString(@"Crop", @"Toolbar item label")]; + [item setToolTip:NSLocalizedString(@"Crop", @"Tool tip message")]; + [item setImage:[NSImage imageNamed:@"ToolbarCrop"]]; + [item setTarget:self]; + [item setAction:@selector(cropAll:)]; + [toolbarItems setObject:item forKey:SKDocumentToolbarCropItemIdentifier]; + [item release]; + item = [[SKToolbarItem alloc] initWithItemIdentifier:SKDocumentToolbarFullScreenItemIdentifier]; [item setLabel:NSLocalizedString(@"Full Screen", @"Toolbar item label")]; [item setPaletteLabel:NSLocalizedString(@"Full Screen", @"Toolbar item label")]; @@ -3110,6 +3157,7 @@ SKDocumentToolbarZoomToFitItemIdentifier, SKDocumentToolbarRotateRightItemIdentifier, SKDocumentToolbarRotateLeftItemIdentifier, + SKDocumentToolbarCropItemIdentifier, SKDocumentToolbarFullScreenItemIdentifier, SKDocumentToolbarPresentationItemIdentifier, SKDocumentToolbarNewNoteItemIdentifier, @@ -3216,6 +3264,8 @@ } else if (action == @selector(toggleAutoScale:)) { [menuItem setState:[pdfView autoScales] ? NSOnState : NSOffState]; return YES; + } else if (action == @selector(crop:) || action == @selector(cropAll:)) { + return NO == NSIsEmptyRect([pdfView currentSelectionRect]); } else if (action == @selector(toggleLeftSidePane:)) { if ([self isFullScreen]) { if ([leftSideWindow state] == NSDrawerOpenState || [leftSideWindow state] == NSDrawerOpeningState) Modified: trunk/SKPDFView.h =================================================================== --- trunk/SKPDFView.h 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/SKPDFView.h 2007-05-22 09:22:06 UTC (rev 2101) @@ -116,6 +116,8 @@ - (PDFAnnotation *)activeAnnotation; - (void)setActiveAnnotation:(PDFAnnotation *)newAnnotation; +- (NSRect)currentSelectionRect; + - (BOOL)hasReadingBar; - (void)toggleReadingBar; Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/SKPDFView.m 2007-05-22 09:22:06 UTC (rev 2101) @@ -322,10 +322,14 @@ float radius = 4.0 / [self scaleFactor]; CGContextBeginPath(context); CGContextAddRect(context, *(CGRect *)&bounds); - if ([activePage isEqual:pdfPage] && NSIsEmptyRect(selectionRect) == NO) - CGContextAddRect(context, *(CGRect *)&selectionRect); + CGContextAddRect(context, *(CGRect *)&selectionRect); CGContextSetFillColor(context, color); CGContextEOFillPath(context); + if ([activePage isEqual:pdfPage] == NO) { + color[3] = 0.4; + CGContextSetFillColor(context, color); + CGContextFillRect(context, *(CGRect *)&selectionRect); + } if ([activePage isEqual:pdfPage] && NSEqualRects(selectionRect, NSZeroRect) == NO) { SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMinY(selectionRect)), radius); SKCGContextDrawGrabHandle(context, CGPointMake(NSMinX(selectionRect), NSMaxY(selectionRect)), radius); @@ -446,6 +450,12 @@ [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFViewActiveAnnotationDidChangeNotification object:self userInfo:nil]; } +- (NSRect)currentSelectionRect { + if (toolMode == SKSelectToolMode || activePage) + return selectionRect; + return NSZeroRect; +} + #pragma mark Reading bar - (BOOL)hasReadingBar { @@ -2615,15 +2625,15 @@ if (NSMinX(newRect) < NSMinX(pageBounds) || NSMaxX(newRect) > NSMaxX(pageBounds) || NSMinY(newRect) < NSMinY(pageBounds) || NSMaxY(newRect) > NSMaxY(pageBounds)) newRect = NSIntersectionRect(newRect, pageBounds); - if (needsDisplay) { + //if (needsDisplay) { [self setNeedsDisplay:YES]; needsDisplay = NO; - } else { - if (NSEqualRects(selectionRect, NSZeroRect) == NO) - [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin, -margin) ofPage:activePage]; - if (NSEqualRects(newRect, NSZeroRect) == NO) - [self setNeedsDisplayInRect:NSInsetRect(newRect, -margin, -margin) ofPage:activePage]; - } + //} else { + // if (NSEqualRects(selectionRect, NSZeroRect) == NO) + // [self setNeedsDisplayInRect:NSInsetRect(selectionRect, -margin, -margin) ofPage:activePage]; + // if (NSEqualRects(newRect, NSZeroRect) == NO) + // [self setNeedsDisplayInRect:NSInsetRect(newRect, -margin, -margin) ofPage:activePage]; + //} selectionRect = newRect; } Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-05-21 17:29:30 UTC (rev 2100) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-05-22 09:22:06 UTC (rev 2101) @@ -80,6 +80,7 @@ CE2DEB920B86206400D0DA12 /* FindPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE2DEB900B86206400D0DA12 /* FindPanel.nib */; }; CE2DED6C0B86334900D0DA12 /* BDSKFindFieldEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DED6B0B86334900D0DA12 /* BDSKFindFieldEditor.m */; }; CE31A6180C01FC45003612A9 /* SKDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE31A6160C01FC45003612A9 /* SKDocumentController.m */; }; + CE31AC4E0C02E919003612A9 /* ToolbarCrop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE31AC4D0C02E918003612A9 /* ToolbarCrop.tiff */; }; CE380A7B0B834E6200A1B779 /* CameraCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */; }; CE380C620B837B6100A1B779 /* NoteViewAdorn.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380C600B837B6100A1B779 /* NoteViewAdorn.tiff */; }; CE380C630B837B6100A1B779 /* SnapshotViewAdorn.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380C610B837B6100A1B779 /* SnapshotViewAdorn.tiff */; }; @@ -376,6 +377,7 @@ CE2DED6B0B86334900D0DA12 /* BDSKFindFieldEditor.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = BDSKFindFieldEditor.m; sourceTree = "<group>"; }; CE31A6150C01FC45003612A9 /* SKDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDocumentController.h; sourceTree = "<group>"; }; CE31A6160C01FC45003612A9 /* SKDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDocumentController.m; sourceTree = "<group>"; }; + CE31AC4D0C02E918003612A9 /* ToolbarCrop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ToolbarCrop.tiff; path = Images/ToolbarCrop.tiff; sourceTree = "<group>"; }; CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = CameraCursor.tiff; path = Images/CameraCursor.tiff; sourceTree = "<group>"; }; CE380C600B837B6100A1B779 /* NoteViewAdorn.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = NoteViewAdorn.tiff; path = Images/NoteViewAdorn.tiff; sourceTree = "<group>"; }; CE380C610B837B6100A1B779 /* SnapshotViewAdorn.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = SnapshotViewAdorn.tiff; path = Images/SnapshotViewAdorn.tiff; sourceTree = "<group>"; }; @@ -904,6 +906,7 @@ CE4EB8230B7B96D00091F228 /* ThumbnailViewAdorn.tiff */, CE7C5D180BD8086C0011315D /* ToolbarArrowNote.tiff */, CE4190C20B94963A00ECF819 /* ToolbarCircleNote.tiff */, + CE31AC4D0C02E918003612A9 /* ToolbarCrop.tiff */, CE5478BA0B33456300F8AFB6 /* ToolbarFullScreen.tiff */, CE9DC2E80B9F131800D64F28 /* ToolbarHighlightNote.tiff */, CE7467330B7F2ED700CBF969 /* ToolbarInfo.tiff */, @@ -1145,6 +1148,7 @@ CE468C470BF1F0F60007AA12 /* TextNoteToolAdorn.tiff in Resources */, CE468C480BF1F0F60007AA12 /* AnchoredNoteToolAdorn.tiff in Resources */, CECBA5910BFCEE260030AB59 /* SelectToolAdorn.tiff in Resources */, + CE31AC4E0C02E919003612A9 /* ToolbarCrop.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-05-21 17:29:31
|
Revision: 2100 http://skim-app.svn.sourceforge.net/skim-app/?rev=2100&view=rev Author: amaxwell Date: 2007-05-21 10:29:30 -0700 (Mon, 21 May 2007) Log Message: ----------- Link against AppKit so NSAttributedString can be unarchived Modified Paths: -------------- trunk/SkimImporter/GetMetadataForFile.m trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj Modified: trunk/SkimImporter/GetMetadataForFile.m =================================================================== --- trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 17:03:19 UTC (rev 2099) +++ trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 17:29:30 UTC (rev 2100) @@ -36,10 +36,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include <CoreFoundation/CoreFoundation.h> +#import <CoreFoundation/CoreFoundation.h> #import <Foundation/Foundation.h> +#import <AppKit/AppKit.h> - Boolean GetMetadataForFile(void* thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, @@ -49,11 +49,6 @@ /* Return the attribute keys and attribute values in the dict */ /* Return TRUE if successful, FALSE if there was no data provided */ -#warning importer crashes - // Got exception *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSFont) for path ... and I'm not sure if importers can link against AppKit - - return TRUE; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Boolean success = FALSE; Modified: trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj =================================================================== --- trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj 2007-05-21 17:03:19 UTC (rev 2099) +++ trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj 2007-05-21 17:29:30 UTC (rev 2100) @@ -16,6 +16,7 @@ C88FB7E40674480E006EBB30 /* schema.strings in Resources */ = {isa = PBXBuildFile; fileRef = C88FB7E30674480E006EBB30 /* schema.strings */; }; CEFD60CF0C01D0E40027B933 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEFD60CE0C01D0E40027B933 /* Foundation.framework */; }; CEFD60D30C01D1040027B933 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEFD60D20C01D1040027B933 /* ApplicationServices.framework */; }; + F91570600C020DDF008B68E9 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F915705F0C020DDF008B68E9 /* AppKit.framework */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -34,6 +35,7 @@ CEFD6C630C01EF7A0027B933 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/schema.strings; sourceTree = "<group>"; }; CEFD6C660C01EF820027B933 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/InfoPlist.strings; sourceTree = "<group>"; }; CEFD6C670C01EF850027B933 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + F915705F0C020DDF008B68E9 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = /System/Library/Frameworks/AppKit.framework; sourceTree = "<absolute>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -45,6 +47,7 @@ C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */, CEFD60CF0C01D0E40027B933 /* Foundation.framework in Frameworks */, CEFD60D30C01D1040027B933 /* ApplicationServices.framework in Frameworks */, + F91570600C020DDF008B68E9 /* AppKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -65,6 +68,7 @@ 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = { isa = PBXGroup; children = ( + F915705F0C020DDF008B68E9 /* AppKit.framework */, CEFD60D20C01D1040027B933 /* ApplicationServices.framework */, CEFD60CE0C01D0E40027B933 /* Foundation.framework */, C86B05260671AA6E00DD9006 /* CoreServices.framework */, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-05-21 17:03:22
|
Revision: 2099 http://skim-app.svn.sourceforge.net/skim-app/?rev=2099&view=rev Author: amaxwell Date: 2007-05-21 10:03:19 -0700 (Mon, 21 May 2007) Log Message: ----------- Export UTI so the importer actually works Modified Paths: -------------- trunk/Info.plist Modified: trunk/Info.plist =================================================================== --- trunk/Info.plist 2007-05-21 17:02:43 UTC (rev 2098) +++ trunk/Info.plist 2007-05-21 17:03:19 UTC (rev 2099) @@ -279,5 +279,27 @@ <string>Skim.sdef</string> <key>SUFeedURL</key> <string>http://skim-app.sourceforge.net/skim.xml</string> + <key>UTExportedTypeDeclarations</key> + <array> + <dict> + <key>UTTypeConformsTo</key> + <array> + <string>public.data</string> + </array> + <key>UTTypeDescription</key> + <string>Skim Notes</string> + <key>UTTypeIconFile</key> + <string>NoteDocument</string> + <key>UTTypeIdentifier</key> + <string>net.sourceforge.skim-app.skimnotes</string> + <key>UTTypeTagSpecification</key> + <dict> + <key>public.filename-extension</key> + <array> + <string>skim</string> + </array> + </dict> + </dict> + </array> </dict> </plist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-05-21 17:02:44
|
Revision: 2098 http://skim-app.svn.sourceforge.net/skim-app/?rev=2098&view=rev Author: amaxwell Date: 2007-05-21 10:02:43 -0700 (Mon, 21 May 2007) Log Message: ----------- Fix memory leak. Add warning, since this doesn't work yet. Modified Paths: -------------- trunk/SkimImporter/GetMetadataForFile.m Modified: trunk/SkimImporter/GetMetadataForFile.m =================================================================== --- trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 17:01:17 UTC (rev 2097) +++ trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 17:02:43 UTC (rev 2098) @@ -39,45 +39,53 @@ #include <CoreFoundation/CoreFoundation.h> #import <Foundation/Foundation.h> + Boolean GetMetadataForFile(void* thisInterface, - CFMutableDictionaryRef attributes, - CFStringRef contentTypeUTI, - CFStringRef pathToFile) + CFMutableDictionaryRef attributes, + CFStringRef contentTypeUTI, + CFStringRef pathToFile) { /* Pull any available metadata from the file at the specified path */ /* Return the attribute keys and attribute values in the dict */ /* Return TRUE if successful, FALSE if there was no data provided */ +#warning importer crashes + // Got exception *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (NSFont) for path ... and I'm not sure if importers can link against AppKit + + return TRUE; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; Boolean success = FALSE; if (UTTypeEqual(contentTypeUTI, CFSTR("net.sourceforge.skim-app.skimnotes"))) { - NSData *data = [[NSData alloc] initWithContentsOfFile:(NSString *)pathToFile options:0 error:NULL]; + NSData *data = [[NSData alloc] initWithContentsOfFile:(NSString *)pathToFile options:NSUncachedRead error:NULL]; if (data) { NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + [data release]; + if (array) { NSEnumerator *noteEnum = [array objectEnumerator]; NSDictionary *note; - NSMutableString *string = [[NSMutableString alloc] init]; + NSMutableString *textContent = [[NSMutableString alloc] init]; NSMutableArray *notes = [[NSMutableArray alloc] init]; while (note = [noteEnum nextObject]) { NSString *contents = [note objectForKey:@"contents"]; if (contents) { - if ([string length]) - [string appendString:@"\n\n"]; - [string appendString:contents]; + if ([textContent length]) + [textContent appendString:@"\n\n"]; + [textContent appendString:contents]; [notes addObject:contents]; } - contents = [[note objectForKey:@"text"] string]; - if (contents) { - if ([string length]) - [string appendString:@"\n\n"]; - [string appendString:contents]; + NSString *text = [[note objectForKey:@"text"] string]; + if (text) { + if ([textContent length]) + [textContent appendString:@"\n\n"]; + [textContent appendString:text]; } } - [(NSMutableDictionary *)attributes setObject:string forKey:(NSString *)kMDItemTextContent]; - [(NSMutableDictionary *)attributes setObject:notes forKey:@"net_sourceforge_skim-app_notes"]; - [string release]; + [(NSMutableDictionary *)attributes setObject:textContent forKey:(NSString *)kMDItemTextContent]; + [(NSMutableDictionary *)attributes setObject:notes forKey:@"net_sourceforge_skim_app_notes"]; + [textContent release]; [notes release]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ama...@us...> - 2007-05-21 17:01:19
|
Revision: 2097 http://skim-app.svn.sourceforge.net/skim-app/?rev=2097&view=rev Author: amaxwell Date: 2007-05-21 10:01:17 -0700 (Mon, 21 May 2007) Log Message: ----------- Fix schema validation errors; apparently the dash is illegal Modified Paths: -------------- trunk/SkimImporter/Dutch.lproj/schema.strings trunk/SkimImporter/English.lproj/schema.strings trunk/SkimImporter/Italian.lproj/schema.strings trunk/SkimImporter/schema.xml Modified: trunk/SkimImporter/Dutch.lproj/schema.strings =================================================================== (Binary files differ) Modified: trunk/SkimImporter/English.lproj/schema.strings =================================================================== (Binary files differ) Modified: trunk/SkimImporter/Italian.lproj/schema.strings =================================================================== (Binary files differ) Modified: trunk/SkimImporter/schema.xml =================================================================== --- trunk/SkimImporter/schema.xml 2007-05-21 16:18:07 UTC (rev 2096) +++ trunk/SkimImporter/schema.xml 2007-05-21 17:01:17 UTC (rev 2097) @@ -9,7 +9,7 @@ are CFNumber, CFDate, CFBoolean and CFData. </note> <attributes> - <attribute name="net_sourceforge_skim-app_notes" multivalued="true" type="CFString"/> + <attribute name="net_sourceforge_skim_app_notes" multivalued="true" type="CFString"/> </attributes> <types> @@ -18,13 +18,13 @@ The keys that this metadata importer handles. </note> <allattrs> - net_sourceforge_skim-app_notes + net_sourceforge_skim_app_notes </allattrs> <displayattrs> kMDItemWhereFroms kMDItemContentModificationDate kMDItemContentCreationDate - net_sourceforge_skim-app_notes + net_sourceforge_skim_app_notes </displayattrs> </type> </types> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-21 16:18:11
|
Revision: 2096 http://skim-app.svn.sourceforge.net/skim-app/?rev=2096&view=rev Author: hofman Date: 2007-05-21 09:18:07 -0700 (Mon, 21 May 2007) Log Message: ----------- Move documentController to separate file. Hack to open the PDF when opening Skim notes from Spotlight. Modified Paths: -------------- trunk/SKDocument.h trunk/SKDocument.m trunk/SKNotesDocument.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/SKDocumentController.h trunk/SKDocumentController.m Modified: trunk/SKDocument.h =================================================================== --- trunk/SKDocument.h 2007-05-21 16:16:23 UTC (rev 2095) +++ trunk/SKDocument.h 2007-05-21 16:18:07 UTC (rev 2096) @@ -42,14 +42,7 @@ extern NSString *SKDocumentWillSaveNotification; -extern NSString *SKPDFDocumentType; -extern NSString *SKEmbeddedPDFDocumentType; -extern NSString *SKBarePDFDocumentType; -extern NSString *SKNotesDocumentType; -extern NSString *SKNotesRTFDocumentType; -extern NSString *SKPostScriptDocumentType; - @class PDFDocument, SKMainWindowController, SKPDFView, SKPDFSynchronizer; @interface SKDocument : NSDocument @@ -104,8 +97,3 @@ - (NSString *)string; @end - - -@interface SKDocumentController : NSDocumentController -- (void)newDocumentFromClipboard:(id)sender; -@end Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-05-21 16:16:23 UTC (rev 2095) +++ trunk/SKDocument.m 2007-05-21 16:18:07 UTC (rev 2096) @@ -50,20 +50,13 @@ #import "SKNoteWindowController.h" #import "SKPDFSynchronizer.h" #import "NSString_SKExtensions.h" +#import "SKDocumentController.h" // maximum length of xattr value recommended by Apple #define MAX_XATTR_LENGTH 2048 NSString *SKDocumentErrorDomain = @"SKDocumentErrorDomain"; -// See CFBundleTypeName in Info.plist -NSString *SKPDFDocumentType = nil; /* set to NSPDFPboardType, not @"NSPDFPboardType" */ -NSString *SKEmbeddedPDFDocumentType = @"PDF With Embedded Notes"; -NSString *SKBarePDFDocumentType = @"PDF Without Notes"; -NSString *SKNotesDocumentType = @"Skim Notes"; -NSString *SKNotesRTFDocumentType = @"Notes as RTF"; -NSString *SKPostScriptDocumentType = @"PostScript document"; - NSString *SKDocumentWillSaveNotification = @"SKDocumentWillSaveNotification"; @@ -864,97 +857,3 @@ } @end - - -@implementation SKDocumentController - -+ (void)initialize { - if (nil == SKPDFDocumentType) - SKPDFDocumentType = [NSPDFPboardType copy]; -} - -- (NSString *)typeFromFileExtension:(NSString *)fileExtensionOrHFSFileType { - NSString *type = [super typeFromFileExtension:fileExtensionOrHFSFileType]; - if ([type isEqualToString:SKEmbeddedPDFDocumentType] || [type isEqualToString:SKBarePDFDocumentType]) { - // fix of bug when reading a PDF file - // this is interpreted as SKEmbeddedPDFDocumentType, even though we don't declare that as a readable type - type = NSPDFPboardType; - } - return type; -} - -static NSData *convertTIFFDataToPDF(NSData *tiffData) -{ - // this should accept any image data types we're likely to run across, but PICT returns a zero size image - CGImageSourceRef imsrc = CGImageSourceCreateWithData((CFDataRef)tiffData, (CFDictionaryRef)[NSDictionary dictionaryWithObject:(id)kUTTypeTIFF forKey:(id)kCGImageSourceTypeIdentifierHint]); - - NSMutableData *pdfData = nil; - - if (CGImageSourceGetCount(imsrc)) { - CGImageRef cgImage = CGImageSourceCreateImageAtIndex(imsrc, 0, NULL); - - pdfData = [NSMutableData dataWithCapacity:[tiffData length]]; - CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData); - - // create full size image, assuming pixel == point - const CGRect rect = CGRectMake(0, 0, CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)); - - CGContextRef ctxt = CGPDFContextCreate(consumer, &rect, NULL); - CGPDFContextBeginPage(ctxt, NULL); - CGContextDrawImage(ctxt, rect, cgImage); - CGPDFContextEndPage(ctxt); - - CGContextFlush(ctxt); - - CGDataConsumerRelease(consumer); - CGContextRelease(ctxt); - CGImageRelease(cgImage); - } - - CFRelease(imsrc); - - return pdfData; -} - -- (void)newDocumentFromClipboard:(id)sender { - - // allow any filter services to convert to TIFF data if we can't get PDF or PS directly - NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; - NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]]; - if (nil == pboardType) { - NSBeep(); - return; - } - - NSData *data = [pboard dataForType:pboardType]; - - // if it's image data, convert to PDF, then explicitly set the pboard type to PDF - if ([pboardType isEqualToString:NSTIFFPboardType]) { - data = convertTIFFDataToPDF(data); - pboardType = NSPDFPboardType; - } - - NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ? SKPostScriptDocumentType : SKPDFDocumentType; - NSError *error = nil; - id document = [self makeUntitledDocumentOfType:type error:&error]; - - if ([document readFromData:data ofType:type error:&error]) { - [self addDocument:document]; - [document makeWindowControllers]; - [document showWindows]; - } else { - [NSApp presentError:error]; - } -} - -- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { - if ([anItem action] == @selector(newDocumentFromClipboard:)) { - NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; - return ([[pboard types] firstObjectCommonWithArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]] != nil); - } else if ([super respondsToSelector:_cmd]) { - return [super validateUserInterfaceItem:anItem]; - } else - return YES; -} - -@end Added: trunk/SKDocumentController.h =================================================================== --- trunk/SKDocumentController.h (rev 0) +++ trunk/SKDocumentController.h 2007-05-21 16:18:07 UTC (rev 2096) @@ -0,0 +1,51 @@ +// +// SKDocumentController.h +// Skim +// +// Created by Christiaan Hofman on 5/21/07. +/* + This software is Copyright (c) 2007 + 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> + +extern NSString *SKPDFDocumentType; +extern NSString *SKEmbeddedPDFDocumentType; +extern NSString *SKBarePDFDocumentType; +extern NSString *SKNotesDocumentType; +extern NSString *SKNotesRTFDocumentType; +extern NSString *SKPostScriptDocumentType; + + +@interface SKDocumentController : NSDocumentController +- (void)newDocumentFromClipboard:(id)sender; +@end Added: trunk/SKDocumentController.m =================================================================== --- trunk/SKDocumentController.m (rev 0) +++ trunk/SKDocumentController.m 2007-05-21 16:18:07 UTC (rev 2096) @@ -0,0 +1,155 @@ +// +// SKDocumentController.m +// Skim +// +// Created by Christiaan Hofman on 5/21/07. +/* + This software is Copyright (c) 2007 + 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 "SKDocumentController.h" + +// See CFBundleTypeName in Info.plist +NSString *SKPDFDocumentType = nil; /* set to NSPDFPboardType, not @"NSPDFPboardType" */ +NSString *SKEmbeddedPDFDocumentType = @"PDF With Embedded Notes"; +NSString *SKBarePDFDocumentType = @"PDF Without Notes"; +NSString *SKNotesDocumentType = @"Skim Notes"; +NSString *SKNotesRTFDocumentType = @"Notes as RTF"; +NSString *SKPostScriptDocumentType = @"PostScript document"; + + +@implementation SKDocumentController + ++ (void)initialize { + if (nil == SKPDFDocumentType) + SKPDFDocumentType = [NSPDFPboardType copy]; +} + +- (NSString *)typeFromFileExtension:(NSString *)fileExtensionOrHFSFileType { + NSString *type = [super typeFromFileExtension:fileExtensionOrHFSFileType]; + if ([type isEqualToString:SKEmbeddedPDFDocumentType] || [type isEqualToString:SKBarePDFDocumentType]) { + // fix of bug when reading a PDF file + // this is interpreted as SKEmbeddedPDFDocumentType, even though we don't declare that as a readable type + type = NSPDFPboardType; + } + return type; +} + +static NSData *convertTIFFDataToPDF(NSData *tiffData) +{ + // this should accept any image data types we're likely to run across, but PICT returns a zero size image + CGImageSourceRef imsrc = CGImageSourceCreateWithData((CFDataRef)tiffData, (CFDictionaryRef)[NSDictionary dictionaryWithObject:(id)kUTTypeTIFF forKey:(id)kCGImageSourceTypeIdentifierHint]); + + NSMutableData *pdfData = nil; + + if (CGImageSourceGetCount(imsrc)) { + CGImageRef cgImage = CGImageSourceCreateImageAtIndex(imsrc, 0, NULL); + + pdfData = [NSMutableData dataWithCapacity:[tiffData length]]; + CGDataConsumerRef consumer = CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData); + + // create full size image, assuming pixel == point + const CGRect rect = CGRectMake(0, 0, CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)); + + CGContextRef ctxt = CGPDFContextCreate(consumer, &rect, NULL); + CGPDFContextBeginPage(ctxt, NULL); + CGContextDrawImage(ctxt, rect, cgImage); + CGPDFContextEndPage(ctxt); + + CGContextFlush(ctxt); + + CGDataConsumerRelease(consumer); + CGContextRelease(ctxt); + CGImageRelease(cgImage); + } + + CFRelease(imsrc); + + return pdfData; +} + +- (void)newDocumentFromClipboard:(id)sender { + + // allow any filter services to convert to TIFF data if we can't get PDF or PS directly + NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; + NSString *pboardType = [pboard availableTypeFromArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]]; + if (nil == pboardType) { + NSBeep(); + return; + } + + NSData *data = [pboard dataForType:pboardType]; + + // if it's image data, convert to PDF, then explicitly set the pboard type to PDF + if ([pboardType isEqualToString:NSTIFFPboardType]) { + data = convertTIFFDataToPDF(data); + pboardType = NSPDFPboardType; + } + + NSString *type = [pboardType isEqualToString:NSPostScriptPboardType] ? SKPostScriptDocumentType : SKPDFDocumentType; + NSError *error = nil; + id document = [self makeUntitledDocumentOfType:type error:&error]; + + if ([document readFromData:data ofType:type error:&error]) { + [self addDocument:document]; + [document makeWindowControllers]; + [document showWindows]; + } else { + [NSApp presentError:error]; + } +} + +- (id)openDocumentWithContentsOfURL:(NSURL *)absoluteURL display:(BOOL)displayDocument error:(NSError **)outError { + NSString *type = [self typeForContentsOfURL:absoluteURL error:NULL]; + if ([type isEqualToString:SKNotesDocumentType]) { + NSAppleEventDescriptor *event = [[NSAppleEventManager sharedAppleEventManager] currentAppleEvent]; + if ([event eventID] == kAEOpenDocuments && [event descriptorForKeyword:keyAESearchText]) { + NSString *pdfFile = [[[absoluteURL path] stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdf"]; + BOOL isDir; + if ([[NSFileManager defaultManager] fileExistsAtPath:pdfFile isDirectory:&isDir] && isDir == NO) + absoluteURL = [NSURL fileURLWithPath:pdfFile]; + } + } + return [super openDocumentWithContentsOfURL:absoluteURL display:displayDocument error:outError]; +} + +- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem { + if ([anItem action] == @selector(newDocumentFromClipboard:)) { + NSPasteboard *pboard = [NSPasteboard pasteboardByFilteringTypesInPasteboard:[NSPasteboard generalPasteboard]]; + return ([[pboard types] firstObjectCommonWithArray:[NSArray arrayWithObjects:NSPDFPboardType, NSPostScriptPboardType, NSTIFFPboardType, nil]] != nil); + } else if ([super respondsToSelector:_cmd]) { + return [super validateUserInterfaceItem:anItem]; + } else + return YES; +} + +@end Modified: trunk/SKNotesDocument.m =================================================================== --- trunk/SKNotesDocument.m 2007-05-21 16:16:23 UTC (rev 2095) +++ trunk/SKNotesDocument.m 2007-05-21 16:18:07 UTC (rev 2096) @@ -40,6 +40,7 @@ #import "SKDocument.h" #import "SKNoteOutlineView.h" #import "BDAlias.h" +#import "SKDocumentController.h" @implementation SKNotesDocument Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-05-21 16:16:23 UTC (rev 2095) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-05-21 16:18:07 UTC (rev 2096) @@ -79,6 +79,7 @@ CE2DEB1C0B8618DE00D0DA12 /* SKFindController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DEB1B0B8618DE00D0DA12 /* SKFindController.m */; }; CE2DEB920B86206400D0DA12 /* FindPanel.nib in Resources */ = {isa = PBXBuildFile; fileRef = CE2DEB900B86206400D0DA12 /* FindPanel.nib */; }; CE2DED6C0B86334900D0DA12 /* BDSKFindFieldEditor.m in Sources */ = {isa = PBXBuildFile; fileRef = CE2DED6B0B86334900D0DA12 /* BDSKFindFieldEditor.m */; }; + CE31A6180C01FC45003612A9 /* SKDocumentController.m in Sources */ = {isa = PBXBuildFile; fileRef = CE31A6160C01FC45003612A9 /* SKDocumentController.m */; }; CE380A7B0B834E6200A1B779 /* CameraCursor.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */; }; CE380C620B837B6100A1B779 /* NoteViewAdorn.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380C600B837B6100A1B779 /* NoteViewAdorn.tiff */; }; CE380C630B837B6100A1B779 /* SnapshotViewAdorn.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CE380C610B837B6100A1B779 /* SnapshotViewAdorn.tiff */; }; @@ -232,14 +233,14 @@ isa = PBXContainerItemProxy; containerPortal = CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */; proxyType = 2; - remoteGlobalIDString = 8D576316048677EA00EA77CD /* SkimImporter.mdimporter */; + remoteGlobalIDString = 8D576316048677EA00EA77CD; remoteInfo = SkimImporter; }; CEFD68700C01D3E50027B933 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */; proxyType = 1; - remoteGlobalIDString = 8D57630D048677EA00EA77CD /* SkimImporter */; + remoteGlobalIDString = 8D57630D048677EA00EA77CD; remoteInfo = SkimImporter; }; /* End PBXContainerItemProxy section */ @@ -373,6 +374,8 @@ CE2DEB910B86206400D0DA12 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/FindPanel.nib; sourceTree = "<group>"; }; CE2DED6A0B86334900D0DA12 /* BDSKFindFieldEditor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = BDSKFindFieldEditor.h; sourceTree = "<group>"; }; CE2DED6B0B86334900D0DA12 /* BDSKFindFieldEditor.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = BDSKFindFieldEditor.m; sourceTree = "<group>"; }; + CE31A6150C01FC45003612A9 /* SKDocumentController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKDocumentController.h; sourceTree = "<group>"; }; + CE31A6160C01FC45003612A9 /* SKDocumentController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKDocumentController.m; sourceTree = "<group>"; }; CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = CameraCursor.tiff; path = Images/CameraCursor.tiff; sourceTree = "<group>"; }; CE380C600B837B6100A1B779 /* NoteViewAdorn.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = NoteViewAdorn.tiff; path = Images/NoteViewAdorn.tiff; sourceTree = "<group>"; }; CE380C610B837B6100A1B779 /* SnapshotViewAdorn.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = SnapshotViewAdorn.tiff; path = Images/SnapshotViewAdorn.tiff; sourceTree = "<group>"; }; @@ -741,6 +744,8 @@ CE0463CA0B84D24300C11E4A /* SKApplication.m */, 4530D8C70B27B04D007C59F4 /* SKApplicationController.h */, 4530D8C80B27B04D007C59F4 /* SKApplicationController.m */, + CE31A6150C01FC45003612A9 /* SKDocumentController.h */, + CE31A6160C01FC45003612A9 /* SKDocumentController.m */, 2A37F4AEFDCFA73011CA2CEA /* SKDocument.h */, 2A37F4ACFDCFA73011CA2CEA /* SKDocument.m */, CEE106130BCBB72C00BF2D3E /* SKNotesDocument.h */, @@ -1299,6 +1304,7 @@ CE49728B0BDE8B2900D7F1D2 /* SKToolbarItem.m in Sources */, CE6C03F10BEDF759007BF0B5 /* NSParagraphStyle_SKExtensions.m in Sources */, CE5F42AF0BF89FE00069D89C /* AppleRemote.m in Sources */, + CE31A6180C01FC45003612A9 /* SKDocumentController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-21 16:16:25
|
Revision: 2095 http://skim-app.svn.sourceforge.net/skim-app/?rev=2095&view=rev Author: hofman Date: 2007-05-21 09:16:23 -0700 (Mon, 21 May 2007) Log Message: ----------- Add licensing info. Modified Paths: -------------- trunk/SkimImporter/GetMetadataForFile.m Modified: trunk/SkimImporter/GetMetadataForFile.m =================================================================== --- trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 15:38:39 UTC (rev 2094) +++ trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 16:16:23 UTC (rev 2095) @@ -1,7 +1,44 @@ +// +// GetMetadataForFile.m +// SkimImporter +// +// Created by Christiaan Hofman on 5/21/07. +/* + This software is Copyright (c) 2007 + 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. + */ + #include <CoreFoundation/CoreFoundation.h> #import <Foundation/Foundation.h> - Boolean GetMetadataForFile(void* thisInterface, CFMutableDictionaryRef attributes, CFStringRef contentTypeUTI, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-21 15:38:40
|
Revision: 2094 http://skim-app.svn.sourceforge.net/skim-app/?rev=2094&view=rev Author: hofman Date: 2007-05-21 08:38:39 -0700 (Mon, 21 May 2007) Log Message: ----------- Add dutch and italian localization to importer. Display only the contents of the notes, as a multivalued attribute. Modified Paths: -------------- trunk/SkimImporter/English.lproj/schema.strings trunk/SkimImporter/GetMetadataForFile.m trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj trunk/SkimImporter/schema.xml Added Paths: ----------- trunk/SkimImporter/Dutch.lproj/ trunk/SkimImporter/Dutch.lproj/InfoPlist.strings trunk/SkimImporter/Dutch.lproj/schema.strings trunk/SkimImporter/Italian.lproj/ trunk/SkimImporter/Italian.lproj/InfoPlist.strings trunk/SkimImporter/Italian.lproj/schema.strings Added: trunk/SkimImporter/Dutch.lproj/InfoPlist.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/Dutch.lproj/InfoPlist.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/SkimImporter/Dutch.lproj/schema.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/Dutch.lproj/schema.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/SkimImporter/English.lproj/schema.strings =================================================================== (Binary files differ) Modified: trunk/SkimImporter/GetMetadataForFile.m =================================================================== --- trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 13:34:48 UTC (rev 2093) +++ trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 15:38:39 UTC (rev 2094) @@ -22,24 +22,31 @@ NSEnumerator *noteEnum = [array objectEnumerator]; NSDictionary *note; NSMutableString *string = [[NSMutableString alloc] init]; + NSMutableArray *notes = [[NSMutableArray alloc] init]; while (note = [noteEnum nextObject]) { NSString *contents = [note objectForKey:@"contents"]; - if ([string length]) - [string appendString:@"\n\n"]; - if (contents) + if (contents) { + if ([string length]) + [string appendString:@"\n\n"]; [string appendString:contents]; + [notes addObject:contents]; + } contents = [[note objectForKey:@"text"] string]; if (contents) { if ([string length]) - [string appendString:@"\n"]; + [string appendString:@"\n\n"]; [string appendString:contents]; } } [(NSMutableDictionary *)attributes setObject:string forKey:(NSString *)kMDItemTextContent]; + [(NSMutableDictionary *)attributes setObject:notes forKey:@"net_sourceforge_skim-app_notes"]; [string release]; + [notes release]; } } + [(NSMutableDictionary *)attributes setObject:@"Skim" forKey:(NSString *)kMDItemCreator]; + NSString *pdfFile = [[(NSString *)pathToFile stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdf"]; if ([[NSFileManager defaultManager] fileExistsAtPath:pdfFile]) [(NSMutableDictionary *)attributes setObject:[NSArray arrayWithObjects:pdfFile, nil] forKey:(NSString *)kMDItemWhereFroms]; Added: trunk/SkimImporter/Italian.lproj/InfoPlist.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/Italian.lproj/InfoPlist.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/SkimImporter/Italian.lproj/schema.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/Italian.lproj/schema.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj =================================================================== --- trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj 2007-05-21 13:34:48 UTC (rev 2093) +++ trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj 2007-05-21 15:38:39 UTC (rev 2094) @@ -30,6 +30,10 @@ C88FB7DB0674470F006EBB30 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/schema.strings; sourceTree = "<group>"; }; CEFD60CE0C01D0E40027B933 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; CEFD60D20C01D1040027B933 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; }; + CEFD6C620C01EF770027B933 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/schema.strings; sourceTree = "<group>"; }; + CEFD6C630C01EF7A0027B933 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/schema.strings; sourceTree = "<group>"; }; + CEFD6C660C01EF820027B933 /* Dutch */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Dutch; path = Dutch.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + CEFD6C670C01EF850027B933 /* Italian */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Italian; path = Italian.lproj/InfoPlist.strings; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -137,6 +141,14 @@ isa = PBXProject; buildConfigurationList = 70138C880896BE9A00968C2F /* Build configuration list for PBXProject "SkimImporter" */; hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + Dutch, + Italian, + ); mainGroup = 089C166AFE841209C02AAC07 /* SkimImporter */; projectDirPath = ""; targets = ( @@ -185,6 +197,8 @@ isa = PBXVariantGroup; children = ( 089C167EFE841241C02AAC07 /* English */, + CEFD6C660C01EF820027B933 /* Dutch */, + CEFD6C670C01EF850027B933 /* Italian */, ); name = InfoPlist.strings; sourceTree = "<group>"; @@ -193,6 +207,8 @@ isa = PBXVariantGroup; children = ( C88FB7DB0674470F006EBB30 /* English */, + CEFD6C620C01EF770027B933 /* Dutch */, + CEFD6C630C01EF7A0027B933 /* Italian */, ); name = schema.strings; sourceTree = "<group>"; Modified: trunk/SkimImporter/schema.xml =================================================================== --- trunk/SkimImporter/schema.xml 2007-05-21 13:34:48 UTC (rev 2093) +++ trunk/SkimImporter/schema.xml 2007-05-21 15:38:39 UTC (rev 2094) @@ -9,6 +9,7 @@ are CFNumber, CFDate, CFBoolean and CFData. </note> <attributes> + <attribute name="net_sourceforge_skim-app_notes" multivalued="true" type="CFString"/> </attributes> <types> @@ -17,12 +18,13 @@ The keys that this metadata importer handles. </note> <allattrs> + net_sourceforge_skim-app_notes </allattrs> <displayattrs> - kMDItemTextContent kMDItemWhereFroms kMDItemContentModificationDate kMDItemContentCreationDate + net_sourceforge_skim-app_notes </displayattrs> </type> </types> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-21 13:34:55
|
Revision: 2093 http://skim-app.svn.sourceforge.net/skim-app/?rev=2093&view=rev Author: hofman Date: 2007-05-21 06:34:48 -0700 (Mon, 21 May 2007) Log Message: ----------- Add importer for skim notes file. Declare UIT for skim notes files. Modified Paths: -------------- trunk/Info.plist trunk/SKApplicationController.h trunk/SKApplicationController.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/SkimImporter/ trunk/SkimImporter/English.lproj/ trunk/SkimImporter/English.lproj/InfoPlist.strings trunk/SkimImporter/English.lproj/schema.strings trunk/SkimImporter/GetMetadataForFile.m trunk/SkimImporter/Info.plist trunk/SkimImporter/SkimImporter.xcodeproj/ trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj trunk/SkimImporter/Version trunk/SkimImporter/main.c trunk/SkimImporter/schema.xml trunk/SkimImporter/version.plist Modified: trunk/Info.plist =================================================================== --- trunk/Info.plist 2007-05-20 20:41:55 UTC (rev 2092) +++ trunk/Info.plist 2007-05-21 13:34:48 UTC (rev 2093) @@ -54,6 +54,10 @@ <string>Skim Notes</string> <key>CFBundleTypeRole</key> <string>Editor</string> + <key>LSItemContentTypes</key> + <array> + <string>net.sourceforge.skim-app.skimnotes</string> + </array> <key>LSTypeIsPackage</key> <false/> <key>NSDocumentClass</key> Modified: trunk/SKApplicationController.h =================================================================== --- trunk/SKApplicationController.h 2007-05-20 20:41:55 UTC (rev 2092) +++ trunk/SKApplicationController.h 2007-05-21 13:34:48 UTC (rev 2093) @@ -56,4 +56,6 @@ - (SUUpdater *)updater; +- (void)doSpotlightImportIfNeeded; + @end Modified: trunk/SKApplicationController.m =================================================================== --- trunk/SKApplicationController.m 2007-05-20 20:41:55 UTC (rev 2092) +++ trunk/SKApplicationController.m 2007-05-21 13:34:48 UTC (rev 2093) @@ -152,6 +152,7 @@ } if ([[NSUserDefaults standardUserDefaults] boolForKey:SKEnableAppleRemoteKey]) [[AppleRemote sharedRemote] setDelegate:self]; + [self doSpotlightImportIfNeeded]; } - (void)applicationDidBecomeActive:(NSNotification *)aNotification { @@ -265,4 +266,46 @@ } } +- (void)doSpotlightImportIfNeeded { + + // This code finds the spotlight importer and re-runs it if the importer or app version has changed since the last time we launched. + NSArray *pathComponents = [NSArray arrayWithObjects:[[NSBundle mainBundle] bundlePath], @"Contents", @"Library", @"Spotlight", @"SkimImporter", nil]; + NSString *importerPath = [[NSString pathWithComponents:pathComponents] stringByAppendingPathExtension:@"mdimporter"]; + + NSBundle *importerBundle = [NSBundle bundleWithPath:importerPath]; + NSString *importerVersion = [importerBundle objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; + if (importerVersion) { + SKVersionNumber *importerVersionNumber = [[[SKVersionNumber alloc] initWithVersionString:importerVersion] autorelease]; + NSDictionary *versionInfo = [[NSUserDefaults standardUserDefaults] dictionaryForKey:@"SKSpotlightVersionInfo"]; + + long sysVersion; + OSStatus err = Gestalt(gestaltSystemVersion, &sysVersion); + + BOOL runImporter = NO; + if ([versionInfo count] == 0) { + runImporter = YES; + } else { + NSString *lastImporterVersion = [versionInfo objectForKey:@"lastImporterVersion"]; + SKVersionNumber *lastImporterVersionNumber = [[[SKVersionNumber alloc] initWithVersionString:lastImporterVersion] autorelease]; + + long lastSysVersion = [[versionInfo objectForKey:@"lastSysVersion"] longValue]; + + runImporter = noErr == err ? ([lastImporterVersionNumber compareToVersionNumber:importerVersionNumber] == NSOrderedAscending || sysVersion > lastSysVersion) : YES; + } + if (runImporter) { + NSString *mdimportPath = @"/usr/bin/mdimport"; + if ([[NSFileManager defaultManager] isExecutableFileAtPath:mdimportPath]) { + NSTask *importerTask = [[[NSTask alloc] init] autorelease]; + [importerTask setLaunchPath:mdimportPath]; + [importerTask setArguments:[NSArray arrayWithObjects:@"-r", importerPath, nil]]; + [importerTask launch]; + + NSDictionary *info = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithLong:sysVersion], @"lastSysVersion", importerVersion, @"lastImporterVersion", nil]; + [[NSUserDefaults standardUserDefaults] setObject:info forKey:@"SKSpotlightVersionInfo"]; + + } else NSLog(@"%@ not found!", mdimportPath); + } + } +} + @end Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-05-20 20:41:55 UTC (rev 2092) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-05-21 13:34:48 UTC (rev 2093) @@ -171,6 +171,7 @@ CEF711A10B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF711A00B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m */; }; CEF7175C0B90DEEF003A2771 /* ReleaseNotes.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEF717560B90DEEF003A2771 /* ReleaseNotes.nib */; }; CEF7175F0B90DF10003A2771 /* SKReleaseNotesController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */; }; + CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in CopyFiles */ = {isa = PBXBuildFile; fileRef = CEFD68690C01D3BB0027B933 /* SkimImporter.mdimporter */; }; CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */; }; F92DB5AC0B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5A90B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m */; }; F92DB5AD0B36FE1F002A26E9 /* BDSKZoomablePDFView.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5AB0B36FE1F002A26E9 /* BDSKZoomablePDFView.m */; }; @@ -227,6 +228,20 @@ remoteGlobalIDString = 8D15AC270486D014006FF6A4; remoteInfo = Skim; }; + CEFD68680C01D3BB0027B933 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 8D576316048677EA00EA77CD /* SkimImporter.mdimporter */; + remoteInfo = SkimImporter; + }; + CEFD68700C01D3E50027B933 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 8D57630D048677EA00EA77CD /* SkimImporter */; + remoteInfo = SkimImporter; + }; /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -251,6 +266,16 @@ ); runOnlyForDeploymentPostprocessing = 0; }; + CEFD68720C01D3FE0027B933 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = Contents/Library/Spotlight; + dstSubfolderSpec = 1; + files = ( + CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -487,6 +512,7 @@ CEF717570B90DEEF003A2771 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ReleaseNotes.nib; sourceTree = "<group>"; }; CEF7175D0B90DF10003A2771 /* SKReleaseNotesController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SKReleaseNotesController.h; sourceTree = "<group>"; }; CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SKReleaseNotesController.m; sourceTree = "<group>"; }; + CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SkimImporter.xcodeproj; path = SkimImporter/SkimImporter.xcodeproj; sourceTree = "<group>"; }; CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKNavigationWindow.h; sourceTree = "<group>"; }; CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKNavigationWindow.m; sourceTree = "<group>"; }; F92DB5A80B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDSKHeaderPopUpButtonCell.h; sourceTree = "<group>"; }; @@ -691,6 +717,7 @@ CE2BD8160BD4123D00A5F4DB /* Subprojects */ = { isa = PBXGroup; children = ( + CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */, CE2BD8170BD4127A00A5F4DB /* Sparkle.xcodeproj */, ); name = Subprojects; @@ -914,6 +941,14 @@ name = Skimnotes; sourceTree = "<group>"; }; + CEFD68620C01D3BB0027B933 /* Products */ = { + isa = PBXGroup; + children = ( + CEFD68690C01D3BB0027B933 /* SkimImporter.mdimporter */, + ); + name = Products; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -927,6 +962,7 @@ 8D15AC330486D014006FF6A4 /* Frameworks */, CEE112760BCBF52500BF2D3E /* CopyFiles */, CEE22EA00BFB8614002B746B /* CopyFiles */, + CEFD68720C01D3FE0027B933 /* CopyFiles */, CEE22EA50BFB8691002B746B /* ShellScript */, CE4B67590BF4DC3000A73E42 /* ShellScript */, CE4DA9060B9E17890039E89C /* ShellScript */, @@ -937,6 +973,7 @@ CE157D890B9F89CE00D5B03F /* PBXTargetDependency */, CE2BD8610BD4144000A5F4DB /* PBXTargetDependency */, CE1E39880BDBCC930011D9DD /* PBXTargetDependency */, + CEFD68710C01D3E50027B933 /* PBXTargetDependency */, ); name = Skim; productInstallPath = "$(HOME)/Applications"; @@ -979,6 +1016,10 @@ projectDirPath = ""; projectReferences = ( { + ProductGroup = CEFD68620C01D3BB0027B933 /* Products */; + ProjectRef = CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */; + }, + { ProductGroup = CE2BD8180BD4127A00A5F4DB /* Products */; ProjectRef = CE2BD8170BD4127A00A5F4DB /* Sparkle.xcodeproj */; }, @@ -1008,6 +1049,13 @@ remoteRef = CE2BD8210BD4127A00A5F4DB /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; + CEFD68690C01D3BB0027B933 /* SkimImporter.mdimporter */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = SkimImporter.mdimporter; + remoteRef = CEFD68680C01D3BB0027B933 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; /* End PBXReferenceProxy section */ /* Begin PBXResourcesBuildPhase section */ @@ -1286,6 +1334,11 @@ target = 8D15AC270486D014006FF6A4 /* Skim */; targetProxy = CE592C610B9239CD00C113DF /* PBXContainerItemProxy */; }; + CEFD68710C01D3E50027B933 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = SkimImporter; + targetProxy = CEFD68700C01D3E50027B933 /* PBXContainerItemProxy */; + }; /* End PBXTargetDependency section */ /* Begin PBXVariantGroup section */ Added: trunk/SkimImporter/English.lproj/InfoPlist.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/English.lproj/InfoPlist.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/SkimImporter/English.lproj/schema.strings =================================================================== (Binary files differ) Property changes on: trunk/SkimImporter/English.lproj/schema.strings ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/SkimImporter/GetMetadataForFile.m =================================================================== --- trunk/SkimImporter/GetMetadataForFile.m (rev 0) +++ trunk/SkimImporter/GetMetadataForFile.m 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,62 @@ +#include <CoreFoundation/CoreFoundation.h> +#import <Foundation/Foundation.h> + + +Boolean GetMetadataForFile(void* thisInterface, + CFMutableDictionaryRef attributes, + CFStringRef contentTypeUTI, + CFStringRef pathToFile) +{ + /* Pull any available metadata from the file at the specified path */ + /* Return the attribute keys and attribute values in the dict */ + /* Return TRUE if successful, FALSE if there was no data provided */ + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + Boolean success = FALSE; + + if (UTTypeEqual(contentTypeUTI, CFSTR("net.sourceforge.skim-app.skimnotes"))) { + NSData *data = [[NSData alloc] initWithContentsOfFile:(NSString *)pathToFile options:0 error:NULL]; + if (data) { + NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:data]; + if (array) { + NSEnumerator *noteEnum = [array objectEnumerator]; + NSDictionary *note; + NSMutableString *string = [[NSMutableString alloc] init]; + while (note = [noteEnum nextObject]) { + NSString *contents = [note objectForKey:@"contents"]; + if ([string length]) + [string appendString:@"\n\n"]; + if (contents) + [string appendString:contents]; + contents = [[note objectForKey:@"text"] string]; + if (contents) { + if ([string length]) + [string appendString:@"\n"]; + [string appendString:contents]; + } + } + [(NSMutableDictionary *)attributes setObject:string forKey:(NSString *)kMDItemTextContent]; + [string release]; + } + } + + NSString *pdfFile = [[(NSString *)pathToFile stringByDeletingPathExtension] stringByAppendingPathExtension:@"pdf"]; + if ([[NSFileManager defaultManager] fileExistsAtPath:pdfFile]) + [(NSMutableDictionary *)attributes setObject:[NSArray arrayWithObjects:pdfFile, nil] forKey:(NSString *)kMDItemWhereFroms]; + + NSDictionary *fileAttributes = [[NSFileManager defaultManager] fileAttributesAtPath:(NSString *)pathToFile traverseLink:YES]; + NSDate *date; + if (date = [fileAttributes objectForKey:NSFileModificationDate]) + [(NSMutableDictionary *)attributes setObject:date forKey:(NSString *)kMDItemContentModificationDate]; + if (date = [fileAttributes objectForKey:NSFileCreationDate]) + [(NSMutableDictionary *)attributes setObject:date forKey:(NSString *)kMDItemContentCreationDate]; + + success = TRUE; + } else { + NSLog(@"Importer asked to handle unknown UTI %@ at path", contentTypeUTI, pathToFile); + } + + [pool release]; + + return success; +} Added: trunk/SkimImporter/Info.plist =================================================================== --- trunk/SkimImporter/Info.plist (rev 0) +++ trunk/SkimImporter/Info.plist 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleDevelopmentRegion</key> + <string>English</string> + <key>CFBundleDocumentTypes</key> + <array> + <dict> + <key>CFBundleTypeRole</key> + <string>MDImporter</string> + <key>LSItemContentTypes</key> + <array> + <string>net.sourceforge.skim-app.skimnotes</string> + </array> + </dict> + </array> + <key>CFBundleExecutable</key> + <string>${EXECUTABLE_NAME}</string> + <key>CFBundleName</key> + <string>${PRODUCT_NAME}</string> + <key>CFBundleIconFile</key> + <string></string> + <key>CFBundleIdentifier</key> + <string>net.sourceforge.skim-app.importer</string> + <key>CFBundleInfoDictionaryVersion</key> + <string>6.0</string> + <key>CFBundleVersion</key> + <string>0.3</string> + <key>CFPlugInDynamicRegisterFunction</key> + <string></string> + <key>CFPlugInDynamicRegistration</key> + <string>NO</string> + <key>CFPlugInFactories</key> + <dict> + <key>7322948B-064A-4A13-9C54-850D15653880</key> + <string>MetadataImporterPluginFactory</string> + </dict> + <key>CFPlugInTypes</key> + <dict> + <key>8B08C4BF-415B-11D8-B3F9-0003936726FC</key> + <array> + <string>7322948B-064A-4A13-9C54-850D15653880</string> + </array> + </dict> + <key>CFPlugInUnloadFunction</key> + <string></string> +</dict> +</plist> Added: trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj =================================================================== --- trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj (rev 0) +++ trunk/SkimImporter/SkimImporter.xcodeproj/project.pbxproj 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,283 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + 2C05A19C06CAA52B00D84F6F /* GetMetadataForFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 2C05A19B06CAA52B00D84F6F /* GetMetadataForFile.m */; }; + 8D576312048677EA00EA77CD /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 08FB77B6FE84183AC02AAC07 /* main.c */; settings = {ATTRIBUTES = (); }; }; + 8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */; }; + 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D5B49A704867FD3000E48DA /* InfoPlist.strings */; }; + C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C86B05260671AA6E00DD9006 /* CoreServices.framework */; }; + C88FB7D8067446EC006EBB30 /* schema.xml in Resources */ = {isa = PBXBuildFile; fileRef = C88FB7D7067446EC006EBB30 /* schema.xml */; }; + C88FB7E40674480E006EBB30 /* schema.strings in Resources */ = {isa = PBXBuildFile; fileRef = C88FB7E30674480E006EBB30 /* schema.strings */; }; + CEFD60CF0C01D0E40027B933 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEFD60CE0C01D0E40027B933 /* Foundation.framework */; }; + CEFD60D30C01D1040027B933 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEFD60D20C01D1040027B933 /* ApplicationServices.framework */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; + 08FB77B6FE84183AC02AAC07 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; }; + 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = /System/Library/Frameworks/CoreFoundation.framework; sourceTree = "<absolute>"; }; + 2C05A19B06CAA52B00D84F6F /* GetMetadataForFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GetMetadataForFile.m; sourceTree = "<group>"; }; + 8D576316048677EA00EA77CD /* SkimImporter.mdimporter */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SkimImporter.mdimporter; sourceTree = BUILT_PRODUCTS_DIR; }; + 8D576317048677EA00EA77CD /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; }; + C86B05260671AA6E00DD9006 /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = /System/Library/Frameworks/CoreServices.framework; sourceTree = "<absolute>"; }; + C88FB7D7067446EC006EBB30 /* schema.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = schema.xml; sourceTree = "<group>"; }; + C88FB7DB0674470F006EBB30 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/schema.strings; sourceTree = "<group>"; }; + CEFD60CE0C01D0E40027B933 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; }; + CEFD60D20C01D1040027B933 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 8D576313048677EA00EA77CD /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D576314048677EA00EA77CD /* CoreFoundation.framework in Frameworks */, + C86B05270671AA6E00DD9006 /* CoreServices.framework in Frameworks */, + CEFD60CF0C01D0E40027B933 /* Foundation.framework in Frameworks */, + CEFD60D30C01D1040027B933 /* ApplicationServices.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 089C166AFE841209C02AAC07 /* SkimImporter */ = { + isa = PBXGroup; + children = ( + 08FB77AFFE84173DC02AAC07 /* Source */, + 089C167CFE841241C02AAC07 /* Resources */, + 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */, + 19C28FB6FE9D52B211CA2CBB /* Products */, + ); + name = SkimImporter; + sourceTree = "<group>"; + }; + 089C1671FE841209C02AAC07 /* External Frameworks and Libraries */ = { + isa = PBXGroup; + children = ( + CEFD60D20C01D1040027B933 /* ApplicationServices.framework */, + CEFD60CE0C01D0E40027B933 /* Foundation.framework */, + C86B05260671AA6E00DD9006 /* CoreServices.framework */, + 0AA1909FFE8422F4C02AAC07 /* CoreFoundation.framework */, + ); + name = "External Frameworks and Libraries"; + sourceTree = "<group>"; + }; + 089C167CFE841241C02AAC07 /* Resources */ = { + isa = PBXGroup; + children = ( + C88FB7E30674480E006EBB30 /* schema.strings */, + C88FB7D7067446EC006EBB30 /* schema.xml */, + 8D576317048677EA00EA77CD /* Info.plist */, + 8D5B49A704867FD3000E48DA /* InfoPlist.strings */, + ); + name = Resources; + sourceTree = "<group>"; + }; + 08FB77AFFE84173DC02AAC07 /* Source */ = { + isa = PBXGroup; + children = ( + 2C05A19B06CAA52B00D84F6F /* GetMetadataForFile.m */, + 08FB77B6FE84183AC02AAC07 /* main.c */, + ); + name = Source; + sourceTree = "<group>"; + }; + 19C28FB6FE9D52B211CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 8D576316048677EA00EA77CD /* SkimImporter.mdimporter */, + ); + name = Products; + sourceTree = "<group>"; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 8D57630E048677EA00EA77CD /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 8D57630D048677EA00EA77CD /* SkimImporter */ = { + isa = PBXNativeTarget; + buildConfigurationList = 70138C840896BE9A00968C2F /* Build configuration list for PBXNativeTarget "SkimImporter" */; + buildPhases = ( + 8D57630E048677EA00EA77CD /* Headers */, + 8D57630F048677EA00EA77CD /* Resources */, + 8D576311048677EA00EA77CD /* Sources */, + 8D576313048677EA00EA77CD /* Frameworks */, + 8D576315048677EA00EA77CD /* Rez */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SkimImporter; + productInstallPath = /Library/Spotlight; + productName = SkimImporter; + productReference = 8D576316048677EA00EA77CD /* SkimImporter.mdimporter */; + productType = "com.apple.product-type.bundle"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 089C1669FE841209C02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 70138C880896BE9A00968C2F /* Build configuration list for PBXProject "SkimImporter" */; + hasScannedForEncodings = 1; + mainGroup = 089C166AFE841209C02AAC07 /* SkimImporter */; + projectDirPath = ""; + targets = ( + 8D57630D048677EA00EA77CD /* SkimImporter */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 8D57630F048677EA00EA77CD /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D5B49A804867FD3000E48DA /* InfoPlist.strings in Resources */, + C88FB7D8067446EC006EBB30 /* schema.xml in Resources */, + C88FB7E40674480E006EBB30 /* schema.strings in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXRezBuildPhase section */ + 8D576315048677EA00EA77CD /* Rez */ = { + isa = PBXRezBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXRezBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 8D576311048677EA00EA77CD /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 8D576312048677EA00EA77CD /* main.c in Sources */, + 2C05A19C06CAA52B00D84F6F /* GetMetadataForFile.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 8D5B49A704867FD3000E48DA /* InfoPlist.strings */ = { + isa = PBXVariantGroup; + children = ( + 089C167EFE841241C02AAC07 /* English */, + ); + name = InfoPlist.strings; + sourceTree = "<group>"; + }; + C88FB7E30674480E006EBB30 /* schema.strings */ = { + isa = PBXVariantGroup; + children = ( + C88FB7DB0674470F006EBB30 /* English */, + ); + name = schema.strings; + sourceTree = "<group>"; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 70138C850896BE9A00968C2F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_MODEL_TUNING = G5; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = /Library/Spotlight; + LIBRARY_STYLE = Bundle; + PRODUCT_NAME = SkimImporter; + WRAPPER_EXTENSION = mdimporter; + ZERO_LINK = YES; + }; + name = Debug; + }; + 70138C860896BE9A00968C2F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + ppc, + i386, + ); + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_MODEL_TUNING = G5; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + INFOPLIST_FILE = Info.plist; + INSTALL_PATH = /Library/Spotlight; + LIBRARY_STYLE = Bundle; + PRODUCT_NAME = SkimImporter; + WRAPPER_EXTENSION = mdimporter; + }; + name = Release; + }; + 70138C890896BE9A00968C2F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Debug; + }; + 70138C8A0896BE9A00968C2F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 70138C840896BE9A00968C2F /* Build configuration list for PBXNativeTarget "SkimImporter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 70138C850896BE9A00968C2F /* Debug */, + 70138C860896BE9A00968C2F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 70138C880896BE9A00968C2F /* Build configuration list for PBXProject "SkimImporter" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 70138C890896BE9A00968C2F /* Debug */, + 70138C8A0896BE9A00968C2F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 089C1669FE841209C02AAC07 /* Project object */; +} Added: trunk/SkimImporter/Version =================================================================== --- trunk/SkimImporter/Version (rev 0) +++ trunk/SkimImporter/Version 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,2 @@ +Release 2 +June 6, 2004 \ No newline at end of file Added: trunk/SkimImporter/main.c =================================================================== --- trunk/SkimImporter/main.c (rev 0) +++ trunk/SkimImporter/main.c 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,225 @@ +// +// main.c +// SkimImporter +// +// Created by Christiaan Hofman on 21/5/07. +// Copyright (c) 2007 __MyCompanyName__. All rights reserved. +// + + + + + +//============================================================================== +// +// DO NO MODIFY THE CONTENT OF THIS FILE +// +// This file contains the generic CFPlug-in code necessary for your importer +// To complete your importer implement the function in GetMetadataForFile.c +// +//============================================================================== + + + + + + +#include <CoreFoundation/CoreFoundation.h> +#include <CoreFoundation/CFPlugInCOM.h> +#include <CoreServices/CoreServices.h> + +// ----------------------------------------------------------------------------- +// constants +// ----------------------------------------------------------------------------- + + +#define PLUGIN_ID "7322948B-064A-4A13-9C54-850D15653880" + +// +// Below is the generic glue code for all plug-ins. +// +// You should not have to modify this code aside from changing +// names if you decide to change the names defined in the Info.plist +// + + +// ----------------------------------------------------------------------------- +// typedefs +// ----------------------------------------------------------------------------- + +// The import function to be implemented in GetMetadataForFile.c +Boolean GetMetadataForFile(void *thisInterface, + CFMutableDictionaryRef attributes, + CFStringRef contentTypeUTI, + CFStringRef pathToFile); + +// The layout for an instance of MetaDataImporterPlugIn +typedef struct __MetadataImporterPluginType +{ + MDImporterInterfaceStruct *conduitInterface; + CFUUIDRef factoryID; + UInt32 refCount; +} MetadataImporterPluginType; + +// ----------------------------------------------------------------------------- +// prototypes +// ----------------------------------------------------------------------------- +// Forward declaration for the IUnknown implementation. +// + +MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID); +void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance); +HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv); +void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID); +ULONG MetadataImporterPluginAddRef(void *thisInstance); +ULONG MetadataImporterPluginRelease(void *thisInstance); +// ----------------------------------------------------------------------------- +// testInterfaceFtbl definition +// ----------------------------------------------------------------------------- +// The TestInterface function table. +// + +static MDImporterInterfaceStruct testInterfaceFtbl = { + NULL, + MetadataImporterQueryInterface, + MetadataImporterPluginAddRef, + MetadataImporterPluginRelease, + GetMetadataForFile +}; + + +// ----------------------------------------------------------------------------- +// AllocMetadataImporterPluginType +// ----------------------------------------------------------------------------- +// Utility function that allocates a new instance. +// You can do some initial setup for the importer here if you wish +// like allocating globals etc... +// +MetadataImporterPluginType *AllocMetadataImporterPluginType(CFUUIDRef inFactoryID) +{ + MetadataImporterPluginType *theNewInstance; + + theNewInstance = (MetadataImporterPluginType *)malloc(sizeof(MetadataImporterPluginType)); + memset(theNewInstance,0,sizeof(MetadataImporterPluginType)); + + /* Point to the function table */ + theNewInstance->conduitInterface = &testInterfaceFtbl; + + /* Retain and keep an open instance refcount for each factory. */ + theNewInstance->factoryID = CFRetain(inFactoryID); + CFPlugInAddInstanceForFactory(inFactoryID); + + /* This function returns the IUnknown interface so set the refCount to one. */ + theNewInstance->refCount = 1; + return theNewInstance; +} + +// ----------------------------------------------------------------------------- +// DeallocSkimImporterMDImporterPluginType +// ----------------------------------------------------------------------------- +// Utility function that deallocates the instance when +// the refCount goes to zero. +// In the current implementation importer interfaces are never deallocated +// but implement this as this might change in the future +// +void DeallocMetadataImporterPluginType(MetadataImporterPluginType *thisInstance) +{ + CFUUIDRef theFactoryID; + + theFactoryID = thisInstance->factoryID; + free(thisInstance); + if (theFactoryID){ + CFPlugInRemoveInstanceForFactory(theFactoryID); + CFRelease(theFactoryID); + } +} + +// ----------------------------------------------------------------------------- +// MetadataImporterQueryInterface +// ----------------------------------------------------------------------------- +// Implementation of the IUnknown QueryInterface function. +// +HRESULT MetadataImporterQueryInterface(void *thisInstance,REFIID iid,LPVOID *ppv) +{ + CFUUIDRef interfaceID; + + interfaceID = CFUUIDCreateFromUUIDBytes(kCFAllocatorDefault,iid); + + if (CFEqual(interfaceID,kMDImporterInterfaceID)){ + /* If the Right interface was requested, bump the ref count, + * set the ppv parameter equal to the instance, and + * return good status. + */ + ((MetadataImporterPluginType*)thisInstance)->conduitInterface->AddRef(thisInstance); + *ppv = thisInstance; + CFRelease(interfaceID); + return S_OK; + }else{ + if (CFEqual(interfaceID,IUnknownUUID)){ + /* If the IUnknown interface was requested, same as above. */ + ((MetadataImporterPluginType*)thisInstance )->conduitInterface->AddRef(thisInstance); + *ppv = thisInstance; + CFRelease(interfaceID); + return S_OK; + }else{ + /* Requested interface unknown, bail with error. */ + *ppv = NULL; + CFRelease(interfaceID); + return E_NOINTERFACE; + } + } +} + +// ----------------------------------------------------------------------------- +// MetadataImporterPluginAddRef +// ----------------------------------------------------------------------------- +// Implementation of reference counting for this type. Whenever an interface +// is requested, bump the refCount for the instance. NOTE: returning the +// refcount is a convention but is not required so don't rely on it. +// +ULONG MetadataImporterPluginAddRef(void *thisInstance) +{ + ((MetadataImporterPluginType *)thisInstance )->refCount += 1; + return ((MetadataImporterPluginType*) thisInstance)->refCount; +} + +// ----------------------------------------------------------------------------- +// SampleCMPluginRelease +// ----------------------------------------------------------------------------- +// When an interface is released, decrement the refCount. +// If the refCount goes to zero, deallocate the instance. +// +ULONG MetadataImporterPluginRelease(void *thisInstance) +{ + ((MetadataImporterPluginType*)thisInstance)->refCount -= 1; + if (((MetadataImporterPluginType*)thisInstance)->refCount == 0){ + DeallocMetadataImporterPluginType((MetadataImporterPluginType*)thisInstance ); + return 0; + }else{ + return ((MetadataImporterPluginType*) thisInstance )->refCount; + } +} + +// ----------------------------------------------------------------------------- +// SkimImporterMDImporterPluginFactory +// ----------------------------------------------------------------------------- +// Implementation of the factory function for this type. +// +void *MetadataImporterPluginFactory(CFAllocatorRef allocator,CFUUIDRef typeID) +{ + MetadataImporterPluginType *result; + CFUUIDRef uuid; + + /* If correct type is being requested, allocate an + * instance of TestType and return the IUnknown interface. + */ + if (CFEqual(typeID,kMDImporterTypeID)){ + uuid = CFUUIDCreateFromString(kCFAllocatorDefault,CFSTR(PLUGIN_ID)); + result = AllocMetadataImporterPluginType(uuid); + CFRelease(uuid); + return result; + } + /* If the requested type is incorrect, return NULL. */ + return NULL; +} + Added: trunk/SkimImporter/schema.xml =================================================================== --- trunk/SkimImporter/schema.xml (rev 0) +++ trunk/SkimImporter/schema.xml 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<schema version="1.0" xmlns="http://www.apple.com/metadata" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.apple.com/metadata file:///System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Resources/MetadataSchema.xsd"> + <note> + Custom attributes that this metadata importer supports. Below + is an example of a multivalued string attribute. Other types + are CFNumber, CFDate, CFBoolean and CFData. + </note> + <attributes> + </attributes> + + <types> + <type name="net.sourceforge.skim-app.skimnotes"> + <note> + The keys that this metadata importer handles. + </note> + <allattrs> + </allattrs> + <displayattrs> + kMDItemTextContent + kMDItemWhereFroms + kMDItemContentModificationDate + kMDItemContentCreationDate + </displayattrs> + </type> + </types> +</schema> + Added: trunk/SkimImporter/version.plist =================================================================== --- trunk/SkimImporter/version.plist (rev 0) +++ trunk/SkimImporter/version.plist 2007-05-21 13:34:48 UTC (rev 2093) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>BuildVersion</key> + <string>266</string> + <key>CFBundleShortVersionString</key> + <string>1.0</string> + <key>CFBundleVersion</key> + <string>1.0</string> + <key>ProjectName</key> + <string>DevToolsWizardTemplates</string> + <key>SourceVersion</key> + <string>3070000</string> +</dict> +</plist> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 20:41:56
|
Revision: 2092 http://skim-app.svn.sourceforge.net/skim-app/?rev=2092&view=rev Author: hofman Date: 2007-05-20 13:41:55 -0700 (Sun, 20 May 2007) Log Message: ----------- Set default arrow image in image popup button cell initializer. Modified Paths: -------------- trunk/BDSKImagePopUpButtonCell.m trunk/SKMainWindowController.m Modified: trunk/BDSKImagePopUpButtonCell.m =================================================================== --- trunk/BDSKImagePopUpButtonCell.m 2007-05-20 19:38:39 UTC (rev 2091) +++ trunk/BDSKImagePopUpButtonCell.m 2007-05-20 20:41:55 UTC (rev 2092) @@ -71,9 +71,23 @@ iconActionEnabled = YES; alwaysUsesFirstItemAsSelected = NO; refreshesMenu = NO; - + + static NSImage *defaultArrowImage = nil; + if (defaultArrowImage == nil) { + defaultArrowImage = [[NSImage alloc] initWithSize:NSMakeSize(7.0, 5.0)]; + [defaultArrowImage lockFocus]; + NSBezierPath *path = [NSBezierPath bezierPath]; + [path moveToPoint:NSMakePoint(0.5, 5.0)]; + [path lineToPoint:NSMakePoint(6.5, 5.0)]; + [path lineToPoint:NSMakePoint(3.5, 0.0)]; + [path closePath]; + [[NSColor colorWithDeviceWhite:0.0 alpha:0.75] setFill]; + [path fill]; + [defaultArrowImage unlockFocus]; + } + [self setIconImage: anImage]; - [self setArrowImage: nil]; + [self setArrowImage: defaultArrowImage]; } return self; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-20 19:38:39 UTC (rev 2091) +++ trunk/SKMainWindowController.m 2007-05-20 20:41:55 UTC (rev 2092) @@ -2839,18 +2839,6 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewNoteItemIdentifier]; [item release]; - NSImage *arrowImage = [[[NSImage alloc] initWithSize:NSMakeSize(7.0, 5.0)] autorelease]; - [arrowImage lockFocus]; - NSBezierPath *path = [NSBezierPath bezierPath]; - [path moveToPoint:NSMakePoint(0.5, 5.0)]; - [path lineToPoint:NSMakePoint(6.5, 5.0)]; - [path lineToPoint:NSMakePoint(3.5, 0.0)]; - [path closePath]; - [[NSColor colorWithDeviceWhite:0.0 alpha:0.75] setFill]; - [path fill]; - [arrowImage unlockFocus]; - - [notePopUpButton setArrowImage:arrowImage]; [notePopUpButton setShowsMenuWhenIconClicked:NO]; [[notePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[notePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2881,7 +2869,6 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewCircleNoteItemIdentifier]; [item release]; - [circlePopUpButton setArrowImage:arrowImage]; [circlePopUpButton setShowsMenuWhenIconClicked:NO]; [[circlePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[circlePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2927,7 +2914,6 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewArrowItemIdentifier]; [item release]; - [markupPopUpButton setArrowImage:arrowImage]; [markupPopUpButton setShowsMenuWhenIconClicked:NO]; [[markupPopUpButton cell] setAltersStateOfSelectedItem:YES]; [[markupPopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 19:38:41
|
Revision: 2091 http://skim-app.svn.sourceforge.net/skim-app/?rev=2091&view=rev Author: hofman Date: 2007-05-20 12:38:39 -0700 (Sun, 20 May 2007) Log Message: ----------- Draw arrow image for popup ourselves again, but with different transparency. Is identical to the tiff image. Modified Paths: -------------- trunk/SKMainWindowController.m trunk/Skim.xcodeproj/project.pbxproj Removed Paths: ------------- trunk/Images/ArrowDown.tiff Deleted: trunk/Images/ArrowDown.tiff =================================================================== (Binary files differ) Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-20 15:59:54 UTC (rev 2090) +++ trunk/SKMainWindowController.m 2007-05-20 19:38:39 UTC (rev 2091) @@ -2839,7 +2839,18 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewNoteItemIdentifier]; [item release]; - [notePopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; + NSImage *arrowImage = [[[NSImage alloc] initWithSize:NSMakeSize(7.0, 5.0)] autorelease]; + [arrowImage lockFocus]; + NSBezierPath *path = [NSBezierPath bezierPath]; + [path moveToPoint:NSMakePoint(0.5, 5.0)]; + [path lineToPoint:NSMakePoint(6.5, 5.0)]; + [path lineToPoint:NSMakePoint(3.5, 0.0)]; + [path closePath]; + [[NSColor colorWithDeviceWhite:0.0 alpha:0.75] setFill]; + [path fill]; + [arrowImage unlockFocus]; + + [notePopUpButton setArrowImage:arrowImage]; [notePopUpButton setShowsMenuWhenIconClicked:NO]; [[notePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[notePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2870,7 +2881,7 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewCircleNoteItemIdentifier]; [item release]; - [circlePopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; + [circlePopUpButton setArrowImage:arrowImage]; [circlePopUpButton setShowsMenuWhenIconClicked:NO]; [[circlePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[circlePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2916,7 +2927,7 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewArrowItemIdentifier]; [item release]; - [markupPopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; + [markupPopUpButton setArrowImage:arrowImage]; [markupPopUpButton setShowsMenuWhenIconClicked:NO]; [[markupPopUpButton cell] setAltersStateOfSelectedItem:YES]; [[markupPopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-05-20 15:59:54 UTC (rev 2090) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-05-20 19:38:39 UTC (rev 2091) @@ -171,7 +171,6 @@ CEF711A10B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF711A00B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m */; }; CEF7175C0B90DEEF003A2771 /* ReleaseNotes.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEF717560B90DEEF003A2771 /* ReleaseNotes.nib */; }; CEF7175F0B90DF10003A2771 /* SKReleaseNotesController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */; }; - CEFD467A0C0077910027B933 /* ArrowDown.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CEFD46790C0077900027B933 /* ArrowDown.tiff */; }; CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */; }; F92DB5AC0B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5A90B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m */; }; F92DB5AD0B36FE1F002A26E9 /* BDSKZoomablePDFView.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5AB0B36FE1F002A26E9 /* BDSKZoomablePDFView.m */; }; @@ -488,7 +487,6 @@ CEF717570B90DEEF003A2771 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ReleaseNotes.nib; sourceTree = "<group>"; }; CEF7175D0B90DF10003A2771 /* SKReleaseNotesController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SKReleaseNotesController.h; sourceTree = "<group>"; }; CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SKReleaseNotesController.m; sourceTree = "<group>"; }; - CEFD46790C0077900027B933 /* ArrowDown.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ArrowDown.tiff; path = Images/ArrowDown.tiff; sourceTree = "<group>"; }; CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKNavigationWindow.h; sourceTree = "<group>"; }; CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKNavigationWindow.m; sourceTree = "<group>"; }; F92DB5A80B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDSKHeaderPopUpButtonCell.h; sourceTree = "<group>"; }; @@ -846,7 +844,6 @@ CE4373B30BB5440E00A56987 /* PSDocument.icns */, CE0715890B8A3D6300733CC8 /* NoteDocument.icns */, CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */, - CEFD46790C0077900027B933 /* ArrowDown.tiff */, CE5478B80B33456300F8AFB6 /* BackAdorn.tiff */, CE5478B90B33456300F8AFB6 /* ForwardAdorn.tiff */, CE3A42340B7927D3006B64D3 /* AnchoredNoteAdorn.tiff */, @@ -1095,7 +1092,6 @@ CE468C470BF1F0F60007AA12 /* TextNoteToolAdorn.tiff in Resources */, CE468C480BF1F0F60007AA12 /* AnchoredNoteToolAdorn.tiff in Resources */, CECBA5910BFCEE260030AB59 /* SelectToolAdorn.tiff in Resources */, - CEFD467A0C0077910027B933 /* ArrowDown.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 16:00:00
|
Revision: 2090 http://skim-app.svn.sourceforge.net/skim-app/?rev=2090&view=rev Author: hofman Date: 2007-05-20 08:59:54 -0700 (Sun, 20 May 2007) Log Message: ----------- Event type is not a mask. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-20 15:01:34 UTC (rev 2089) +++ trunk/SKPDFView.m 2007-05-20 15:59:54 UTC (rev 2090) @@ -2721,7 +2721,7 @@ while (YES) { theEvent = [[self window] nextEventMatchingMask: NSLeftMouseUpMask | NSLeftMouseDraggedMask]; - if ([theEvent type] == NSLeftMouseUpMask) + if ([theEvent type] == NSLeftMouseUp) break; // dragging @@ -2771,7 +2771,7 @@ [[self window] restoreCachedImage]; [[self window] flushWindow]; - if ([theEvent type] == NSLeftMouseUpMask) + if ([theEvent type] == NSLeftMouseUp) break; if ([theEvent type] == NSLeftMouseDragged) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 15:01:35
|
Revision: 2089 http://skim-app.svn.sourceforge.net/skim-app/?rev=2089&view=rev Author: hofman Date: 2007-05-20 08:01:34 -0700 (Sun, 20 May 2007) Log Message: ----------- Use image for disclosure triangle of image popup. Modified Paths: -------------- trunk/SKMainWindowController.m trunk/Skim.xcodeproj/project.pbxproj Added Paths: ----------- trunk/Images/ArrowDown.tiff Added: trunk/Images/ArrowDown.tiff =================================================================== (Binary files differ) Property changes on: trunk/Images/ArrowDown.tiff ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-20 09:55:11 UTC (rev 2088) +++ trunk/SKMainWindowController.m 2007-05-20 15:01:34 UTC (rev 2089) @@ -2816,26 +2816,6 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarPresentationItemIdentifier]; [item release]; - NSImage *downArrow = [[[NSImage alloc] initWithSize:NSMakeSize(10, 10)] autorelease]; - { - [downArrow lockFocus]; - [NSGraphicsContext saveGraphicsState]; - [[NSColor clearColor] setFill]; - NSRect r = NSZeroRect; - r.size = [downArrow size]; - NSRectFill(r); - r = NSInsetRect(r, 2.0, 2.0); - NSBezierPath *bezierPath = [NSBezierPath bezierPath]; - [bezierPath moveToPoint:NSMakePoint(NSMinX(r), NSMaxY(r))]; - [bezierPath lineToPoint:NSMakePoint(NSMaxX(r), NSMaxY(r))]; - [bezierPath lineToPoint:NSMakePoint(NSMidX(r), NSMinY(r))]; - [bezierPath closePath]; - [[NSColor blackColor] setFill]; - [bezierPath fill]; - [NSGraphicsContext restoreGraphicsState]; - [downArrow unlockFocus]; - } - menu = [[[NSMenu allocWithZone:[NSMenu menuZone]] initWithTitle:@""] autorelease]; menuItem = [menu addItemWithTitle:NSLocalizedString(@"Text Note", @"Menu item title") action:@selector(createNewNote:) keyEquivalent:@""]; [menuItem setTag:SKFreeTextNote]; @@ -2859,7 +2839,7 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewNoteItemIdentifier]; [item release]; - [notePopUpButton setArrowImage:downArrow]; + [notePopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; [notePopUpButton setShowsMenuWhenIconClicked:NO]; [[notePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[notePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2890,7 +2870,7 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewCircleNoteItemIdentifier]; [item release]; - [circlePopUpButton setArrowImage:downArrow]; + [circlePopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; [circlePopUpButton setShowsMenuWhenIconClicked:NO]; [[circlePopUpButton cell] setAltersStateOfSelectedItem:YES]; [[circlePopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; @@ -2936,7 +2916,7 @@ [toolbarItems setObject:item forKey:SKDocumentToolbarNewArrowItemIdentifier]; [item release]; - [markupPopUpButton setArrowImage:downArrow]; + [markupPopUpButton setArrowImage:[NSImage imageNamed:@"ArrowDown"]]; [markupPopUpButton setShowsMenuWhenIconClicked:NO]; [[markupPopUpButton cell] setAltersStateOfSelectedItem:YES]; [[markupPopUpButton cell] setAlwaysUsesFirstItemAsSelected:NO]; Modified: trunk/Skim.xcodeproj/project.pbxproj =================================================================== --- trunk/Skim.xcodeproj/project.pbxproj 2007-05-20 09:55:11 UTC (rev 2088) +++ trunk/Skim.xcodeproj/project.pbxproj 2007-05-20 15:01:34 UTC (rev 2089) @@ -171,6 +171,7 @@ CEF711A10B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF711A00B90B714003A2771 /* NSUserDefaultsController_SKExtensions.m */; }; CEF7175C0B90DEEF003A2771 /* ReleaseNotes.nib in Resources */ = {isa = PBXBuildFile; fileRef = CEF717560B90DEEF003A2771 /* ReleaseNotes.nib */; }; CEF7175F0B90DF10003A2771 /* SKReleaseNotesController.m in Sources */ = {isa = PBXBuildFile; fileRef = CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */; }; + CEFD467A0C0077910027B933 /* ArrowDown.tiff in Resources */ = {isa = PBXBuildFile; fileRef = CEFD46790C0077900027B933 /* ArrowDown.tiff */; }; CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */; }; F92DB5AC0B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5A90B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m */; }; F92DB5AD0B36FE1F002A26E9 /* BDSKZoomablePDFView.m in Sources */ = {isa = PBXBuildFile; fileRef = F92DB5AB0B36FE1F002A26E9 /* BDSKZoomablePDFView.m */; }; @@ -487,6 +488,7 @@ CEF717570B90DEEF003A2771 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/ReleaseNotes.nib; sourceTree = "<group>"; }; CEF7175D0B90DF10003A2771 /* SKReleaseNotesController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SKReleaseNotesController.h; sourceTree = "<group>"; }; CEF7175E0B90DF10003A2771 /* SKReleaseNotesController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SKReleaseNotesController.m; sourceTree = "<group>"; }; + CEFD46790C0077900027B933 /* ArrowDown.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; name = ArrowDown.tiff; path = Images/ArrowDown.tiff; sourceTree = "<group>"; }; CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKNavigationWindow.h; sourceTree = "<group>"; }; CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKNavigationWindow.m; sourceTree = "<group>"; }; F92DB5A80B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BDSKHeaderPopUpButtonCell.h; sourceTree = "<group>"; }; @@ -844,6 +846,7 @@ CE4373B30BB5440E00A56987 /* PSDocument.icns */, CE0715890B8A3D6300733CC8 /* NoteDocument.icns */, CE380A7A0B834E6100A1B779 /* CameraCursor.tiff */, + CEFD46790C0077900027B933 /* ArrowDown.tiff */, CE5478B80B33456300F8AFB6 /* BackAdorn.tiff */, CE5478B90B33456300F8AFB6 /* ForwardAdorn.tiff */, CE3A42340B7927D3006B64D3 /* AnchoredNoteAdorn.tiff */, @@ -1092,6 +1095,7 @@ CE468C470BF1F0F60007AA12 /* TextNoteToolAdorn.tiff in Resources */, CE468C480BF1F0F60007AA12 /* AnchoredNoteToolAdorn.tiff in Resources */, CECBA5910BFCEE260030AB59 /* SelectToolAdorn.tiff in Resources */, + CEFD467A0C0077910027B933 /* ArrowDown.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 09:55:17
|
Revision: 2088 http://skim-app.svn.sourceforge.net/skim-app/?rev=2088&view=rev Author: hofman Date: 2007-05-20 02:55:11 -0700 (Sun, 20 May 2007) Log Message: ----------- Private method to update the cursor. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-20 08:31:34 UTC (rev 2087) +++ trunk/SKPDFView.m 2007-05-20 09:55:11 UTC (rev 2088) @@ -51,6 +51,7 @@ #import "SKDocument.h" #import "SKPDFSynchronizer.h" #import "PDFSelection_SKExtensions.h" +#import <Carbon/Carbon.h> NSString *SKPDFViewToolModeChangedNotification = @"SKPDFViewToolModeChangedNotification"; NSString *SKPDFViewAnnotationModeChangedNotification = @"SKPDFViewAnnotationModeChangedNotification"; @@ -107,6 +108,7 @@ - (void)dragReadingBarWithEvent:(NSEvent *)theEvent; - (void)pdfsyncWithEvent:(NSEvent *)theEvent; - (NSCursor *)cursorForEvent:(NSEvent *)theEvent; +- (void)updateCursor; @end @@ -398,8 +400,7 @@ toolMode = newToolMode; [[NSUserDefaults standardUserDefaults] setInteger:toolMode forKey:SKLastToolModeKey]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFViewToolModeChangedNotification object:self]; - // hack to make sure we update the cursor - [[self window] makeFirstResponder:self]; + [self updateCursor]; } } @@ -844,32 +845,7 @@ - (void)flagsChanged:(NSEvent *)theEvent { [super flagsChanged:theEvent]; - - NSCursor *cursor = nil; - - if ([theEvent modifierFlags] & NSCommandKeyMask) { - if ([theEvent modifierFlags] & NSShiftKeyMask) - cursor = [NSCursor arrowCursor]; - else - cursor = [NSCursor cameraCursor]; - } else { - switch (toolMode) { - case SKTextToolMode: - case SKNoteToolMode: - cursor = [NSCursor arrowCursor]; - break; - case SKMoveToolMode: - cursor = [NSCursor openHandCursor]; - break; - case SKSelectToolMode: - break; - case SKMagnifyToolMode: - cursor = ([theEvent modifierFlags] & NSShiftKeyMask) ? [NSCursor zoomOutCursor] : [NSCursor zoomInCursor]; - break; - } - } - - [cursor set]; + [self updateCursor]; } - (void)lookUpCurrentSelectionInDictionary:(id)sender; @@ -2845,7 +2821,7 @@ } [[self window] discardCachedImage]; - [self flagsChanged:theEvent]; + [[self cursorForEvent:theEvent] set]; NSPoint point = [self convertPoint:NSMakePoint(NSMidX(selRect), NSMidY(selRect)) fromView:[self documentView]]; PDFPage *page = [self pageForPoint:point nearest:YES]; @@ -2933,7 +2909,7 @@ magScale = (modifierFlags & NSCommandKeyMask) ? 4.0 : (modifierFlags & NSControlKeyMask) ? 1.5 : 2.5; if ((modifierFlags & NSShiftKeyMask) == 0) magScale = 1.0 / magScale; - [self flagsChanged:theEvent]; // update the cursor + [[self cursorForEvent:theEvent] set]; } else if ([theEvent type] == NSLeftMouseDragged) { // get Mouse location and check if it is with the view's rect mouseLoc = [theEvent locationInWindow]; @@ -3001,7 +2977,7 @@ [[self window] flushWindowIfNeeded]; [NSCursor unhide]; [documentView setPostsBoundsChangedNotifications:postNotification]; - [self flagsChanged:theEvent]; // update cursor + [[self cursorForEvent:theEvent] set]; } - (void)pdfsyncWithEvent:(NSEvent *)theEvent { @@ -3074,6 +3050,29 @@ return cursor; } +- (void)updateCursor { + unsigned int flags = 0; + UInt32 currentKeyModifiers = GetCurrentKeyModifiers(); + if (currentKeyModifiers & cmdKey) + flags |= NSCommandKeyMask; + if (currentKeyModifiers & shiftKey) + flags |= NSShiftKeyMask; + if (currentKeyModifiers & optionKey) + flags |= NSAlternateKeyMask; + if (currentKeyModifiers & controlKey) + flags |= NSControlKeyMask; + NSEvent *event = [NSEvent mouseEventWithType:NSMouseMoved + location:[[self window] mouseLocationOutsideOfEventStream] + modifierFlags:flags + timestamp:0 + windowNumber:[[self window] windowNumber] + context:[[self window] graphicsContext] + eventNumber:0 + clickCount:1 + pressure:0.0]; + [[self cursorForEvent:event] set]; +} + @end #pragma mark Core Graphics extension This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-20 08:31:59
|
Revision: 2087 http://skim-app.svn.sourceforge.net/skim-app/?rev=2087&view=rev Author: hofman Date: 2007-05-20 01:31:34 -0700 (Sun, 20 May 2007) Log Message: ----------- Clear other display boxes for copied pages. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-19 19:01:21 UTC (rev 2086) +++ trunk/SKPDFView.m 2007-05-20 08:31:34 UTC (rev 2087) @@ -494,6 +494,9 @@ PDFPage *page = [pdfDoc pageAtIndex:0]; [page setBounds:[activePage boundsForBox:kPDFDisplayBoxMediaBox] forBox:kPDFDisplayBoxMediaBox]; [page setBounds:selectionRect forBox:kPDFDisplayBoxCropBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxBleedBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxTrimBox]; + [page setBounds:NSZeroRect forBox:kPDFDisplayBoxArtBox]; if (pdfData = [page dataRepresentation]) [types addObject:NSPDFPboardType]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-19 19:01:22
|
Revision: 2086 http://skim-app.svn.sourceforge.net/skim-app/?rev=2086&view=rev Author: hofman Date: 2007-05-19 12:01:21 -0700 (Sat, 19 May 2007) Log Message: ----------- Properly add or declare pasteboard types for copying. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-19 16:00:58 UTC (rev 2085) +++ trunk/SKPDFView.m 2007-05-19 19:01:21 UTC (rev 2086) @@ -479,18 +479,30 @@ { [super copy:sender]; + NSMutableArray *types = [NSMutableArray array]; + NSData *noteData = nil; + NSData *pdfData = nil; + NSData *tiffData = nil; + if ([activeAnnotation isNoteAnnotation] && [activeAnnotation isMovable]) { - NSPasteboard *pboard = [NSPasteboard generalPasteboard]; - NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[activeAnnotation dictionaryValue]]; - [pboard declareTypes:[NSArray arrayWithObjects:SKSkimNotePboardType, nil] owner:nil]; - [pboard setData:data forType:SKSkimNotePboardType]; + if (noteData = [NSKeyedArchiver archivedDataWithRootObject:[activeAnnotation dictionaryValue]]) + [types addObject:SKSkimNotePboardType]; } + if (toolMode == SKSelectToolMode && activePage) { + PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[activePage dataRepresentation]]; + PDFPage *page = [pdfDoc pageAtIndex:0]; + [page setBounds:[activePage boundsForBox:kPDFDisplayBoxMediaBox] forBox:kPDFDisplayBoxMediaBox]; + [page setBounds:selectionRect forBox:kPDFDisplayBoxCropBox]; + + if (pdfData = [page dataRepresentation]) + [types addObject:NSPDFPboardType]; + [pdfDoc release]; + NSRect bounds = [activePage boundsForBox:[self displayBox]]; NSRect targetRect = NSZeroRect, sourceRect = selectionRect; NSImage *pageImage = [activePage imageForBox:[self displayBox]]; NSImage *image = nil; - NSData *data = nil; sourceRect.origin.x -= NSMinX(bounds); sourceRect.origin.y -= NSMinY(bounds); @@ -499,7 +511,8 @@ [image lockFocus]; [pageImage drawInRect:targetRect fromRect:sourceRect operation:NSCompositeCopy fraction:1.0]; [image unlockFocus]; - data = [image TIFFRepresentation]; + if (tiffData = [image TIFFRepresentation]) + [types addObject:NSTIFFPboardType]; [image release]; /* @@ -508,20 +521,25 @@ sourceRect = [self convertRect:selectionRect fromPage:activePage]; NSBitmapImageRep *imageRep = [self bitmapImageRepForCachingDisplayInRect:sourceRect]; [self cacheDisplayInRect:sourceRect toBitmapImageRep:imageRep]; - data = [imageRep TIFFRepresentation]; + tiffData = [imageRep TIFFRepresentation]; */ - - PDFDocument *pdfDoc = [[PDFDocument alloc] initWithData:[activePage dataRepresentation]]; - PDFPage *page = [pdfDoc pageAtIndex:0]; - [page setBounds:[activePage boundsForBox:kPDFDisplayBoxMediaBox] forBox:kPDFDisplayBoxMediaBox]; - [page setBounds:selectionRect forBox:kPDFDisplayBoxCropBox]; - - NSPasteboard *pboard = [NSPasteboard generalPasteboard]; - [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType, NSTIFFPboardType, nil] owner:nil]; - [pboard setData:[page dataRepresentation] forType:NSPDFPboardType]; - [pboard setData:data forType:NSTIFFPboardType]; - [pdfDoc release]; } + + NSPasteboard *pboard = [NSPasteboard generalPasteboard]; + + if ([types count]) { + if ([[self currentSelection] string]) + [pboard addTypes:types owner:nil]; + else + [pboard declareTypes:types owner:nil]; + } + + if (noteData) + [pboard setData:noteData forType:SKSkimNotePboardType]; + if (pdfData) + [pboard setData:pdfData forType:NSPDFPboardType]; + if (tiffData) + [pboard setData:tiffData forType:NSTIFFPboardType]; } - (void)pasteNoteAlternate:(BOOL)isAlternate { @@ -1042,6 +1060,9 @@ item = [menu insertItemWithTitle:NSLocalizedString(@"Copy", @"Menu item title") action:@selector(copy:) keyEquivalent:@"" atIndex:0]; } + if ([[menu itemAtIndex:0] isSeparatorItem]) + [menu removeItemAtIndex:0]; + } else if (toolMode == SKSelectToolMode && activePage) { [menu insertItem:[NSMenuItem separatorItem] atIndex:0]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-19 16:01:34
|
Revision: 2085 http://skim-app.svn.sourceforge.net/skim-app/?rev=2085&view=rev Author: hofman Date: 2007-05-19 09:00:58 -0700 (Sat, 19 May 2007) Log Message: ----------- color of grab handles. Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2007-05-19 10:13:38 UTC (rev 2084) +++ trunk/SKPDFView.m 2007-05-19 16:00:58 UTC (rev 2085) @@ -3083,8 +3083,8 @@ static void SKCGContextDrawGrabHandle(CGContextRef context, CGPoint point, float radius) { - float white[4] = { 1.0, 1.0, 1.0, 0.7 }; - float gray[4] = { 0.5, 0.5, 0.6, 0.7 }; + float white[4] = { 1.0, 1.0, 1.0, 0.8 }; + float gray[4] = { 0.0, 0.0, 0.0, 0.4 }; CGRect outerRect = CGRectMake(point.x - radius, point.y - radius, 2.0 * radius, 2.0 * radius); CGRect innerRect = CGRectMake(point.x - 0.75 * radius, point.y - 0.75 * radius, 1.5 * radius, 1.5 * radius); CGContextSetFillColor(context, white); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2007-05-19 10:13:39
|
Revision: 2084 http://skim-app.svn.sourceforge.net/skim-app/?rev=2084&view=rev Author: hofman Date: 2007-05-19 03:13:38 -0700 (Sat, 19 May 2007) Log Message: ----------- Use current display box to copy TIFF data for page. Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2007-05-19 09:42:47 UTC (rev 2083) +++ trunk/SKMainWindowController.m 2007-05-19 10:13:38 UTC (rev 2084) @@ -2419,7 +2419,7 @@ if (index != NSNotFound) { PDFPage *page = [[pdfView document] pageAtIndex:index]; NSData *pdfData = [page dataRepresentation]; - NSData *tiffData = [[page image] TIFFRepresentation]; + NSData *tiffData = [[page imageForBox:[pdfView displayBox]] TIFFRepresentation]; NSPasteboard *pboard = [NSPasteboard generalPasteboard]; [pboard declareTypes:[NSArray arrayWithObjects:NSPDFPboardType, NSTIFFPboardType, nil] owner:nil]; [pboard setData:pdfData forType:NSPDFPboardType]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |