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
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ho...@us...> - 2025-06-08 21:59:04
|
Revision: 15416 http://sourceforge.net/p/skim-app/code/15416 Author: hofman Date: 2025-06-08 21:59:01 +0000 (Sun, 08 Jun 2025) Log Message: ----------- don't use continue Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 21:49:24 UTC (rev 15415) +++ trunk/SKMainWindowController.m 2025-06-08 21:59:01 UTC (rev 15416) @@ -1019,20 +1019,20 @@ for (NSDictionary *dict in noteDicts) { if ([[dict objectForKey:SKNPDFAnnotationTypeKey] isEqualToString:SKNWidgetString]) { [widgetDicts addObject:dict]; - continue; - } - @autoreleasepool{ - PDFAnnotation *annotation = [PDFAnnotation newSkimNoteWithProperties:dict]; - if (annotation) { - NSUInteger pageIndex = [[dict objectForKey:SKNPDFAnnotationPageIndexKey] unsignedIntegerValue]; - if (pageIndex == NSNotFound) - pageIndex = 0; - else if (pageIndex >= [pdfDoc pageCount]) - pageIndex = [pdfDoc pageCount] - 1; - PDFPage *page = [pdfDoc pageAtIndex:pageIndex]; - if (autoUpdate && [[annotation contents] length] == 0) - [annotation autoUpdateStringWithPage:page]; - [notesAndPagesToAdd addObject:@[annotation, page]]; + } else { + @autoreleasepool{ + PDFAnnotation *annotation = [PDFAnnotation newSkimNoteWithProperties:dict]; + if (annotation) { + NSUInteger pageIndex = [[dict objectForKey:SKNPDFAnnotationPageIndexKey] unsignedIntegerValue]; + if (pageIndex == NSNotFound) + pageIndex = 0; + else if (pageIndex >= [pdfDoc pageCount]) + pageIndex = [pdfDoc pageCount] - 1; + PDFPage *page = [pdfDoc pageAtIndex:pageIndex]; + if (autoUpdate && [[annotation contents] length] == 0) + [annotation autoUpdateStringWithPage:page]; + [notesAndPagesToAdd addObject:@[annotation, page]]; + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 21:49:27
|
Revision: 15415 http://sourceforge.net/p/skim-app/code/15415 Author: hofman Date: 2025-06-08 21:49:24 +0000 (Sun, 08 Jun 2025) Log Message: ----------- only set shouldDisplay for Skim notes Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 15:47:49 UTC (rev 15414) +++ trunk/SKMainWindowController.m 2025-06-08 21:49:24 UTC (rev 15415) @@ -979,8 +979,10 @@ for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; PDFPage *page = [annotationAndPage lastObject]; - [annotation setShouldDisplay:shouldDisplay]; - [annotation setShouldPrint:shouldDisplay]; + if ([annotation isSkimNote]) { + [annotation setShouldDisplay:shouldDisplay]; + [annotation setShouldPrint:shouldDisplay]; + } [addedNotes addObject:annotation]; [pageIndexes addIndex:[page pageIndex]]; [pdfDoc addAnnotation:annotation toPage:page]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 15:47:50
|
Revision: 15414 http://sourceforge.net/p/skim-app/code/15414 Author: hofman Date: 2025-06-08 15:47:49 +0000 (Sun, 08 Jun 2025) Log Message: ----------- cache textString when auto updating string for new markup notes Modified Paths: -------------- trunk/PDFAnnotationMarkup_SKExtensions.m Modified: trunk/PDFAnnotationMarkup_SKExtensions.m =================================================================== --- trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 15:18:58 UTC (rev 15413) +++ trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 15:47:49 UTC (rev 15414) @@ -301,8 +301,11 @@ - (void)autoUpdateStringWithPage:(PDFPage *)page { NSString *selString = [[self selectionWithPage:page] cleanedString]; - if ([selString length]) + if ([selString length]) { + // page should be future [self page] and textString will not have been called + objc_setAssociatedObject(self, &SKTextStringKey, selString, OBJC_ASSOCIATION_RETAIN); [self setString:selString]; + } } - (NSSet *)keysForValuesToObserveForUndo { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 15:19:00
|
Revision: 15413 http://sourceforge.net/p/skim-app/code/15413 Author: hofman Date: 2025-06-08 15:18:58 +0000 (Sun, 08 Jun 2025) Log Message: ----------- invert condition Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2025-06-08 14:52:55 UTC (rev 15412) +++ trunk/SKPDFView.m 2025-06-08 15:18:58 UTC (rev 15413) @@ -2395,7 +2395,7 @@ PDFAnnotation *newAnnotation = nil; NSArray *newAnnotations = nil; NSInteger disableUpdateString = [[NSUserDefaults standardUserDefaults] integerForKey:SKDisableUpdateContentsFromEnclosedTextKey]; - NSString *text = disableUpdateString > 1 ? nil : [selection cleanedString]; + NSString *text = disableUpdateString < 2 ? [selection cleanedString] : nil; BOOL isInitial = NSEqualSizes(bounds.size, NSZeroSize) && selection == nil; // new note added by note tool mode, don't add actual zero sized notes This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 14:52:58
|
Revision: 15412 http://sourceforge.net/p/skim-app/code/15412 Author: hofman Date: 2025-06-08 14:52:55 +0000 (Sun, 08 Jun 2025) Log Message: ----------- Check defaults before using autoUpdateStringForrPage: Modified Paths: -------------- trunk/PDFAnnotationCircle_SKExtensions.m trunk/PDFAnnotationMarkup_SKExtensions.m trunk/PDFAnnotationSquare_SKExtensions.m trunk/PDFAnnotation_SKExtensions.m trunk/SKMainWindowController.m trunk/SKPDFView.m Modified: trunk/PDFAnnotationCircle_SKExtensions.m =================================================================== --- trunk/PDFAnnotationCircle_SKExtensions.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/PDFAnnotationCircle_SKExtensions.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -103,9 +103,12 @@ return dx * dx + dy * dy >= 1.0; } +- (void)autoUpdateString { + if (NO == [[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] && [self page]) + [self autoUpdateStringWithPage:[self page]]; +} + - (void)autoUpdateStringWithPage:(PDFPage *)page { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] || page == nil) - return; // this calculation is roughly the inverse of -[PDFView addAnnotationWithType:context:] NSRect bounds = NSInsetRect([self bounds], [self lineWidth] - 1.0, [self lineWidth] - 1.0); CGFloat t, w = NSWidth(bounds), h = NSWidth(bounds); Modified: trunk/PDFAnnotationMarkup_SKExtensions.m =================================================================== --- trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -300,8 +300,6 @@ } - (void)autoUpdateStringWithPage:(PDFPage *)page { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) - return; NSString *selString = [[self selectionWithPage:page] cleanedString]; if ([selString length]) [self setString:selString]; Modified: trunk/PDFAnnotationSquare_SKExtensions.m =================================================================== --- trunk/PDFAnnotationSquare_SKExtensions.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/PDFAnnotationSquare_SKExtensions.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -93,9 +93,12 @@ return NSWidth(bounds) <= 2.0 * delta || NSHeight(bounds) <= 2.0 * delta || NSPointInRect(point, NSInsetRect(bounds, delta, delta)) == NO; } +- (void)autoUpdateString { + if (NO == [[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] && [self page]) + [self autoUpdateStringWithPage:[self page]]; +} + - (void)autoUpdateStringWithPage:(PDFPage *)page { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] || page == nil) - return; NSRect bounds = NSInsetRect([self bounds], [self lineWidth] - 1.0, [self lineWidth] - 1.0); if (NSWidth(bounds) <= 0.0 || NSHeight(bounds) <= 0.0) return; Modified: trunk/PDFAnnotation_SKExtensions.m =================================================================== --- trunk/PDFAnnotation_SKExtensions.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/PDFAnnotation_SKExtensions.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -505,7 +505,8 @@ [self setModificationDate:[NSDate date]]; } -- (void)autoUpdateString { if ([self page]) [self autoUpdateStringWithPage:[self page]]; } +- (void)autoUpdateString {} + - (void)autoUpdateStringWithPage:(PDFPage *)page {} - (NSString *)colorDefaultKey { return nil; } Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/SKMainWindowController.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -1062,7 +1062,8 @@ } - (void)addConvertedAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { - NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:YES widgetDictionaries:nil]; + BOOL autoUpdate = NO == [[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]; + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:autoUpdate widgetDictionaries:nil]; [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; } Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2025-06-08 14:42:15 UTC (rev 15411) +++ trunk/SKPDFView.m 2025-06-08 14:52:55 UTC (rev 15412) @@ -2394,7 +2394,8 @@ - (BOOL)addAnnotationWithType:(SKNoteType)annotationType selection:(PDFSelection *)selection page:(PDFPage *)page bounds:(NSRect)bounds { PDFAnnotation *newAnnotation = nil; NSArray *newAnnotations = nil; - NSString *text = [selection cleanedString]; + NSInteger disableUpdateString = [[NSUserDefaults standardUserDefaults] integerForKey:SKDisableUpdateContentsFromEnclosedTextKey]; + NSString *text = disableUpdateString > 1 ? nil : [selection cleanedString]; BOOL isInitial = NSEqualSizes(bounds.size, NSZeroSize) && selection == nil; // new note added by note tool mode, don't add actual zero sized notes @@ -2401,9 +2402,6 @@ if (isInitial) bounds = annotationType == SKNoteTypeAnchored ? SKRectFromCenterAndSize(bounds.origin, SKNPDFAnnotationNoteSize) : SKRectFromCenterAndSquareSize(bounds.origin, MIN_NOTE_SIZE); - if ([[NSUserDefaults standardUserDefaults] integerForKey:SKDisableUpdateContentsFromEnclosedTextKey] > 1) - text = nil; - // Create annotation and add to page. NSString *type = nil; BOOL isMarkup = NO; @@ -2474,7 +2472,7 @@ if (annotationType != SKNoteTypeLine && annotationType != SKNoteTypeInk) { if ([text length] > 0) [newAnnotation setString:text]; - else if (isInitial == NO) + else if (isInitial == NO && disableUpdateString == 0) [newAnnotation autoUpdateStringWithPage:page]; } if ([newAnnotation string] == nil) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 14:42:17
|
Revision: 15411 http://sourceforge.net/p/skim-app/code/15411 Author: hofman Date: 2025-06-08 14:42:15 +0000 (Sun, 08 Jun 2025) Log Message: ----------- combine setting string for new notes Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2025-06-08 14:35:09 UTC (rev 15410) +++ trunk/SKPDFView.m 2025-06-08 14:42:15 UTC (rev 15411) @@ -2471,13 +2471,15 @@ } else if (newAnnotation) { [self beginNewUndoGroupIfNeededWithCommit:YES]; - if (annotationType != SKNoteTypeLine && annotationType != SKNoteTypeInk && [text length] > 0) - [newAnnotation setString:text]; - [newAnnotation registerUserName]; - if ([text length] == 0 && isInitial == NO) - [newAnnotation autoUpdateStringWithPage:page]; + if (annotationType != SKNoteTypeLine && annotationType != SKNoteTypeInk) { + if ([text length] > 0) + [newAnnotation setString:text]; + else if (isInitial == NO) + [newAnnotation autoUpdateStringWithPage:page]; + } if ([newAnnotation string] == nil) [newAnnotation setString:@""]; + [newAnnotation registerUserName]; [[self document] addAnnotation:newAnnotation toPage:page]; [self setUndoActionName:NSLocalizedString(@"Add Note", @"Undo action name")]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 14:35:10
|
Revision: 15410 http://sourceforge.net/p/skim-app/code/15410 Author: hofman Date: 2025-06-08 14:35:09 +0000 (Sun, 08 Jun 2025) Log Message: ----------- no need to autoUpdateString for new markup notes, as they must have a selection to create Modified Paths: -------------- trunk/SKPDFView.m Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2025-06-08 14:27:29 UTC (rev 15409) +++ trunk/SKPDFView.m 2025-06-08 14:35:09 UTC (rev 15410) @@ -2460,8 +2460,6 @@ if ([text length] > 0 || [newAnnotation string] == nil) [newAnnotation setString:text ?: @""]; [newAnnotation registerUserName]; - if ([text length] == 0 && isInitial == NO) - [newAnnotation autoUpdateStringWithPage:page]; [[self document] addAnnotation:newAnnotation toPage:page]; } [self setUndoActionName:NSLocalizedString(@"Add Note", @"Undo action name")]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 14:27:30
|
Revision: 15409 http://sourceforge.net/p/skim-app/code/15409 Author: hofman Date: 2025-06-08 14:27:29 +0000 (Sun, 08 Jun 2025) Log Message: ----------- no need to override autoUpdateString for markup notes, as they cannot be moved Modified Paths: -------------- trunk/PDFAnnotationMarkup_SKExtensions.m Modified: trunk/PDFAnnotationMarkup_SKExtensions.m =================================================================== --- trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 13:52:21 UTC (rev 15408) +++ trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-08 14:27:29 UTC (rev 15409) @@ -299,14 +299,6 @@ return nil; } -- (void)autoUpdateString { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) - return; - NSString *selString = [self textString]; - if ([selString length]) - [self setString:selString]; -} - - (void)autoUpdateStringWithPage:(PDFPage *)page { if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 13:52:23
|
Revision: 15408 http://sourceforge.net/p/skim-app/code/15408 Author: hofman Date: 2025-06-08 13:52:21 +0000 (Sun, 08 Jun 2025) Log Message: ----------- declare add/remove in bulk so we ignore irrelevant calls Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 08:57:19 UTC (rev 15407) +++ trunk/SKMainWindowController.m 2025-06-08 13:52:21 UTC (rev 15408) @@ -1148,6 +1148,8 @@ NSMutableArray *addedNotes = [NSMutableArray array]; BOOL shouldDisplay = [pdfView hideNotes] == NO; + mwcFlags.addOrRemoveNotesInBulk = 1; + for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; [annotation setShouldDisplay:shouldDisplay]; @@ -1156,6 +1158,8 @@ [addedNotes addObject:annotation]; } + mwcFlags.addOrRemoveNotesInBulk = 0; + [self insertNotes:addedNotes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [addedNotes count])]]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 08:57:21
|
Revision: 15407 http://sourceforge.net/p/skim-app/code/15407 Author: hofman Date: 2025-06-08 08:57:19 +0000 (Sun, 08 Jun 2025) Log Message: ----------- pass whether to replace existing notes rather than notes Modified Paths: -------------- trunk/SKMainDocument.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2025-06-08 08:46:45 UTC (rev 15406) +++ trunk/SKMainDocument.m 2025-06-08 08:57:19 UTC (rev 15407) @@ -1104,7 +1104,7 @@ } if (array) { - [[self mainWindowController] addAnnotationsFromDictionaries:array removeAnnotations:replace ? [self notes] : nil]; + [[self mainWindowController] addAnnotationsFromDictionaries:array replacing:replace]; [[self undoManager] setActionName:replace ? NSLocalizedString(@"Replace Notes", @"Undo action name") : NSLocalizedString(@"Add Notes", @"Undo action name")]; } else NSBeep(); Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2025-06-08 08:46:45 UTC (rev 15406) +++ trunk/SKMainWindowController.h 2025-06-08 08:57:19 UTC (rev 15407) @@ -317,7 +317,7 @@ - (void)allSnapshotsNeedUpdate; - (void)setPdfDocument:(nullable PDFDocument *)pdfDocument addAnnotationsFromDictionaries:(nullable NSArray<NSDictionary<NSString *, id> *> *)noteDicts; -- (void)addAnnotationsFromDictionaries:(NSArray<NSDictionary<NSString *, id> *> *)noteDicts removeAnnotations:(nullable NSArray<PDFAnnotation *> *)notesToRemove; +- (void)addAnnotationsFromDictionaries:(NSArray<NSDictionary<NSString *, id> *> *)noteDicts replacing:(BOOL)replacing; - (void)addConvertedAnnotationsFromDictionaries:(NSArray<NSDictionary<NSString *, id> *> *)noteDicts removeAnnotations:(nullable NSArray<PDFAnnotation *> *)notesToRemove; - (void)applySetup:(NSDictionary<NSString *, id> *)setup; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 08:46:45 UTC (rev 15406) +++ trunk/SKMainWindowController.m 2025-06-08 08:57:19 UTC (rev 15407) @@ -1038,17 +1038,17 @@ return notesAndPagesToAdd; } -- (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { +- (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts replacing:(BOOL)replacing { NSMutableArray *widgetDicts = [NSMutableArray array]; NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:NO widgetDictionaries:widgetDicts]; - if ([notesToRemove count]) { + if (replacing && [notes count]) { [pdfView removePDFToolTipRects]; // remove the current annotations [pdfView setCurrentAnnotation:nil]; } - if (notesToRemove && [widgets count]) { + if (replacing && [widgets count]) { for (PDFAnnotation *widget in widgets) { id origValue = [widgetValues objectForKey:widget]; if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) @@ -1058,7 +1058,7 @@ if ([widgetDicts count]) [self changeWidgetsFromDictionaries:widgetDicts]; - [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; + [self addAnnotations:notesAndPagesToAdd removeAnnotations:replacing ? [self notes] : nil]; } - (void)addConvertedAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 08:46:46
|
Revision: 15406 http://sourceforge.net/p/skim-app/code/15406 Author: hofman Date: 2025-06-08 08:46:45 +0000 (Sun, 08 Jun 2025) Log Message: ----------- no need for setter Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 08:45:07 UTC (rev 15405) +++ trunk/SKMainWindowController.m 2025-06-08 08:46:45 UTC (rev 15406) @@ -919,17 +919,6 @@ placeholderWidgetProperties = nil; } -- (void)setWidgetValues:(NSMapTable *)newWidgetValues { - if (widgetValues) { - [[[self document] undoManager] registerUndoWithTarget:self selector:@selector(setWidgetValues:) object:[widgetValues copy]]; - for (PDFAnnotation *widget in newWidgetValues) { - [widgetValues setObject:[newWidgetValues objectForKey:widget] forKey:widget]; - } - } else { - widgetValues = newWidgetValues; - } -} - - (void)changeWidgetsFromDictionaries:(NSArray *)widgetDicts { for (NSDictionary *dict in widgetDicts) { NSRect bounds = NSIntegralRect(NSRectFromString([dict objectForKey:SKNPDFAnnotationBoundsKey])); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 08:45:09
|
Revision: 15405 http://sourceforge.net/p/skim-app/code/15405 Author: hofman Date: 2025-06-08 08:45:07 +0000 (Sun, 08 Jun 2025) Log Message: ----------- separate methods to add and remove annotations oin bulk for add/replace and for convert Modified Paths: -------------- trunk/SKMainDocument.m trunk/SKMainWindowController.h trunk/SKMainWindowController.m Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2025-06-08 08:37:40 UTC (rev 15404) +++ trunk/SKMainDocument.m 2025-06-08 08:45:07 UTC (rev 15405) @@ -1202,7 +1202,7 @@ dispatch_async(dispatch_get_main_queue(), ^{ - [[self mainWindowController] addAnnotationsFromDictionaries:noteDicts removeAnnotations:annotations]; + [[self mainWindowController] addConvertedAnnotationsFromDictionaries:noteDicts removeAnnotations:annotations]; [self setPDFData:data pageOffsets:offsets]; Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2025-06-08 08:37:40 UTC (rev 15404) +++ trunk/SKMainWindowController.h 2025-06-08 08:45:07 UTC (rev 15405) @@ -318,6 +318,7 @@ - (void)setPdfDocument:(nullable PDFDocument *)pdfDocument addAnnotationsFromDictionaries:(nullable NSArray<NSDictionary<NSString *, id> *> *)noteDicts; - (void)addAnnotationsFromDictionaries:(NSArray<NSDictionary<NSString *, id> *> *)noteDicts removeAnnotations:(nullable NSArray<PDFAnnotation *> *)notesToRemove; +- (void)addConvertedAnnotationsFromDictionaries:(NSArray<NSDictionary<NSString *, id> *> *)noteDicts removeAnnotations:(nullable NSArray<PDFAnnotation *> *)notesToRemove; - (void)applySetup:(NSDictionary<NSString *, id> *)setup; - (NSDictionary<NSString *, id> *)currentSetup; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-08 08:37:40 UTC (rev 15404) +++ trunk/SKMainWindowController.m 2025-06-08 08:45:07 UTC (rev 15405) @@ -984,7 +984,7 @@ [pdfDoc removeAnnotation:annotation]; } } - + if ([notesAndPagesToAdd count]) { BOOL shouldDisplay = [pdfView hideNotes] == NO; for (NSArray *annotationAndPage in notesAndPagesToAdd) { @@ -997,7 +997,7 @@ [pdfDoc addAnnotation:annotation toPage:page]; } } - + mwcFlags.addOrRemoveNotesInBulk = 0; [[[[self document] undoManager] prepareWithInvocationTarget:self] addAnnotations:removedNotesAndPages removeAnnotations:addedNotes]; @@ -1050,32 +1050,34 @@ } - (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { - // notesToRemove is either nil (add), self.notes (replace), or non Skim notes (convert) - BOOL isAddOrReplace = [notesToRemove count] == 0 || [[notesToRemove firstObject] isSkimNote]; - NSMutableArray *widgetDicts = isAddOrReplace ? [NSMutableArray array] : nil; - NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:isAddOrReplace == NO widgetDictionaries:widgetDicts]; + NSMutableArray *widgetDicts = [NSMutableArray array]; + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:NO widgetDictionaries:widgetDicts]; - if (isAddOrReplace) { - if ([notesToRemove count]) { - [pdfView removePDFToolTipRects]; - // remove the current annotations - [pdfView setCurrentAnnotation:nil]; + if ([notesToRemove count]) { + [pdfView removePDFToolTipRects]; + // remove the current annotations + [pdfView setCurrentAnnotation:nil]; + } + + if (notesToRemove && [widgets count]) { + for (PDFAnnotation *widget in widgets) { + id origValue = [widgetValues objectForKey:widget]; + if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) + [widget setObjectValue:origValue]; } - - if (notesToRemove && [widgets count]) { - for (PDFAnnotation *widget in widgets) { - id origValue = [widgetValues objectForKey:widget]; - if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) - [widget setObjectValue:origValue]; - } - } - if ([widgetDicts count]) - [self changeWidgetsFromDictionaries:widgetDicts]; } + if ([widgetDicts count]) + [self changeWidgetsFromDictionaries:widgetDicts]; [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; } +- (void)addConvertedAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:YES widgetDictionaries:nil]; + + [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; +} + - (void)setPdfDocument:(PDFDocument *)pdfDocument addAnnotationsFromDictionaries:(NSArray *)noteDicts { PDFDocument *pdfDoc = pdfDocument; NSMutableArray *widgetProperties = nil; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-08 08:37:43
|
Revision: 15404 http://sourceforge.net/p/skim-app/code/15404 Author: hofman Date: 2025-06-08 08:37:40 +0000 (Sun, 08 Jun 2025) Log Message: ----------- Don't use variabble. Do not reset widgetValues when cpnverting notes, we still save a pdf document with the original widgets, so default values do not have to change Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 22:37:52 UTC (rev 15403) +++ trunk/SKMainWindowController.m 2025-06-08 08:37:40 UTC (rev 15404) @@ -1050,13 +1050,11 @@ } - (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { - // notesToRemove is either [self notes], nil, or non Skim notes + // notesToRemove is either nil (add), self.notes (replace), or non Skim notes (convert) BOOL isAddOrReplace = [notesToRemove count] == 0 || [[notesToRemove firstObject] isSkimNote]; - PDFDocument *pdfDoc = [pdfView document]; NSMutableArray *widgetDicts = isAddOrReplace ? [NSMutableArray array] : nil; + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:[pdfView document] autoUpdate:isAddOrReplace == NO widgetDictionaries:widgetDicts]; - NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:isAddOrReplace == NO widgetDictionaries:widgetDicts]; - if (isAddOrReplace) { if ([notesToRemove count]) { [pdfView removePDFToolTipRects]; @@ -1073,11 +1071,6 @@ } if ([widgetDicts count]) [self changeWidgetsFromDictionaries:widgetDicts]; - } else if ([widgets count]) { - NSMapTable *values = [NSMapTable strongToStrongObjectsMapTable]; - for (PDFAnnotation *widget in widgets) - [values setObject:[widget objectValue] forKey:widget]; - [self setWidgetValues:values]; } [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 22:37:55
|
Revision: 15403 http://sourceforge.net/p/skim-app/code/15403 Author: hofman Date: 2025-06-07 22:37:52 +0000 (Sat, 07 Jun 2025) Log Message: ----------- get undoManager from document Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 22:33:55 UTC (rev 15402) +++ trunk/SKMainWindowController.m 2025-06-07 22:37:52 UTC (rev 15403) @@ -1000,7 +1000,7 @@ mwcFlags.addOrRemoveNotesInBulk = 0; - [[[self undoManager] prepareWithInvocationTarget:self] addAnnotations:removedNotesAndPages removeAnnotations:addedNotes]; + [[[[self document] undoManager] prepareWithInvocationTarget:self] addAnnotations:removedNotesAndPages removeAnnotations:addedNotes]; [removedIndexes removeIndex:NSNotFound]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 22:33:56
|
Revision: 15402 http://sourceforge.net/p/skim-app/code/15402 Author: hofman Date: 2025-06-07 22:33:55 +0000 (Sat, 07 Jun 2025) Log Message: ----------- Combine statements wthin condition block. No need to check for count twice. Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 21:36:23 UTC (rev 15401) +++ trunk/SKMainWindowController.m 2025-06-07 22:33:55 UTC (rev 15402) @@ -1053,17 +1053,17 @@ // notesToRemove is either [self notes], nil, or non Skim notes BOOL isAddOrReplace = [notesToRemove count] == 0 || [[notesToRemove firstObject] isSkimNote]; PDFDocument *pdfDoc = [pdfView document]; - NSMutableArray *widgetDicts = [NSMutableArray array]; + NSMutableArray *widgetDicts = isAddOrReplace ? [NSMutableArray array] : nil; NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:isAddOrReplace == NO widgetDictionaries:widgetDicts]; - if ([notesToRemove count] && isAddOrReplace) { - [pdfView removePDFToolTipRects]; - // remove the current annotations - [pdfView setCurrentAnnotation:nil]; - } - if (isAddOrReplace) { + if ([notesToRemove count]) { + [pdfView removePDFToolTipRects]; + // remove the current annotations + [pdfView setCurrentAnnotation:nil]; + } + if (notesToRemove && [widgets count]) { for (PDFAnnotation *widget in widgets) { id origValue = [widgetValues objectForKey:widget]; @@ -1077,8 +1077,7 @@ NSMapTable *values = [NSMapTable strongToStrongObjectsMapTable]; for (PDFAnnotation *widget in widgets) [values setObject:[widget objectValue] forKey:widget]; - if ([values count]) - [self setWidgetValues:values]; + [self setWidgetValues:values]; } [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 21:36:25
|
Revision: 15401 http://sourceforge.net/p/skim-app/code/15401 Author: hofman Date: 2025-06-07 21:36:23 +0000 (Sat, 07 Jun 2025) Log Message: ----------- get pageindex from page Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 21:25:14 UTC (rev 15400) +++ trunk/SKMainWindowController.m 2025-06-07 21:36:23 UTC (rev 15401) @@ -976,10 +976,11 @@ if ([notesToRemove count]) { for (PDFAnnotation *annotation in notesToRemove) { - [removedNotesAndPages addObject:@[annotation, [annotation page]]]; + PDFPage *page = [annotation page]; + [removedNotesAndPages addObject:@[annotation, page]]; if (removedIndexes) - [removedIndexes addIndex:[notes indexOfObject:annotation]]; - [pageIndexes addIndex:[annotation pageIndex]]; + [removedIndexes addIndex:[notes indexOfObjectIdenticalTo:annotation]]; + [pageIndexes addIndex:[page pageIndex]]; [pdfDoc removeAnnotation:annotation]; } } @@ -988,11 +989,12 @@ BOOL shouldDisplay = [pdfView hideNotes] == NO; for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; + PDFPage *page = [annotationAndPage lastObject]; [annotation setShouldDisplay:shouldDisplay]; [annotation setShouldPrint:shouldDisplay]; [addedNotes addObject:annotation]; - [pageIndexes addIndex:[annotation pageIndex]]; - [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; + [pageIndexes addIndex:[page pageIndex]]; + [pdfDoc addAnnotation:annotation toPage:page]; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 21:25:17
|
Revision: 15400 http://sourceforge.net/p/skim-app/code/15400 Author: hofman Date: 2025-06-07 21:25:14 +0000 (Sat, 07 Jun 2025) Log Message: ----------- top observing document when unlocking Modified Paths: -------------- trunk/SKSecondaryPDFView.m Modified: trunk/SKSecondaryPDFView.m =================================================================== --- trunk/SKSecondaryPDFView.m 2025-06-07 21:06:59 UTC (rev 15399) +++ trunk/SKSecondaryPDFView.m 2025-06-07 21:25:14 UTC (rev 15400) @@ -124,7 +124,7 @@ } - (void)setDocument:(PDFDocument *)document { - if ([self document]) + if ([self document] && [[self document] isLocked]) [[NSNotificationCenter defaultCenter] removeObserver:self name:PDFDocumentDidUnlockNotification object:[self document]]; BOOL savedSwitching = switching; switching = YES; @@ -808,6 +808,7 @@ - (void)handleDocumentDidUnlockNotification:(NSNotification *)notification { [self reloadPagePopUpButton]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:PDFDocumentDidUnlockNotification object:[self document]]; } - (void)handlePDFViewScaleChangedNotification:(NSNotification *)notification { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 21:07:01
|
Revision: 15399 http://sourceforge.net/p/skim-app/code/15399 Author: hofman Date: 2025-06-07 21:06:59 +0000 (Sat, 07 Jun 2025) Log Message: ----------- get widget properties when interpreting note dictionaries Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 20:50:06 UTC (rev 15398) +++ trunk/SKMainWindowController.m 2025-06-07 21:06:59 UTC (rev 15399) @@ -1084,7 +1084,7 @@ - (void)setPdfDocument:(PDFDocument *)pdfDocument addAnnotationsFromDictionaries:(NSArray *)noteDicts { PDFDocument *pdfDoc = pdfDocument; - NSArray *widgetProperties = [noteDicts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type = \"Widget\""]]; + NSMutableArray *widgetProperties = nil; PDFDocument *oldPdfDoc = [pdfView document]; SKDestination dest = {NSNotFound, NSZeroPoint}, secondaryDest = {NSNotFound, NSZeroPoint}; BOOL rotated = NO; @@ -1158,7 +1158,8 @@ } if ([noteDicts count]) { - NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:NO widgetDictionaries:nil]; + widgetProperties = [NSMutableArray array]; + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:NO widgetDictionaries:widgetProperties]; NSMutableArray *addedNotes = [NSMutableArray array]; BOOL shouldDisplay = [pdfView hideNotes] == NO; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 20:50:09
|
Revision: 15398 http://sourceforge.net/p/skim-app/code/15398 Author: hofman Date: 2025-06-07 20:50:06 +0000 (Sat, 07 Jun 2025) Log Message: ----------- set shouldDisplay when adding the note to the page Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 16:04:20 UTC (rev 15397) +++ trunk/SKMainWindowController.m 2025-06-07 20:50:06 UTC (rev 15398) @@ -985,8 +985,11 @@ } if ([notesAndPagesToAdd count]) { + BOOL shouldDisplay = [pdfView hideNotes] == NO; for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; + [annotation setShouldDisplay:shouldDisplay]; + [annotation setShouldPrint:shouldDisplay]; [addedNotes addObject:annotation]; [pageIndexes addIndex:[annotation pageIndex]]; [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; @@ -1018,7 +1021,6 @@ - (NSArray *)annotationsAndPagesFromDictionaries:(NSArray *)noteDicts forDocument:(PDFDocument *)pdfDoc autoUpdate:(BOOL)autoUpdate widgetDictionaries:(NSMutableArray *)widgetDicts { NSMutableArray *notesAndPagesToAdd = [NSMutableArray array]; - BOOL shouldDisplay = [pdfView hideNotes] == NO; // create new annotations from the dictionary and get the page to add to for (NSDictionary *dict in noteDicts) { @@ -1034,8 +1036,6 @@ pageIndex = 0; else if (pageIndex >= [pdfDoc pageCount]) pageIndex = [pdfDoc pageCount] - 1; - [annotation setShouldDisplay:shouldDisplay]; - [annotation setShouldPrint:shouldDisplay]; PDFPage *page = [pdfDoc pageAtIndex:pageIndex]; if (autoUpdate && [[annotation contents] length] == 0) [annotation autoUpdateStringWithPage:page]; @@ -1160,9 +1160,12 @@ if ([noteDicts count]) { NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:NO widgetDictionaries:nil]; NSMutableArray *addedNotes = [NSMutableArray array]; + BOOL shouldDisplay = [pdfView hideNotes] == NO; for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; + [annotation setShouldDisplay:shouldDisplay]; + [annotation setShouldPrint:shouldDisplay]; [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; [addedNotes addObject:annotation]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 16:04:22
|
Revision: 15397 http://sourceforge.net/p/skim-app/code/15397 Author: hofman Date: 2025-06-07 16:04:20 +0000 (Sat, 07 Jun 2025) Log Message: ----------- Undo adding and removing of notes also in bulk Modified Paths: -------------- trunk/SKMainWindowController.h trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.h =================================================================== --- trunk/SKMainWindowController.h 2025-06-07 15:11:08 UTC (rev 15396) +++ trunk/SKMainWindowController.h 2025-06-07 16:04:20 UTC (rev 15397) @@ -242,6 +242,7 @@ - (void)insertObject:(PDFAnnotation *)note inNotesAtIndex:(NSUInteger)theIndex; - (void)insertNotes:(NSArray *)newNotes atIndexes:(NSIndexSet *)theIndexes; - (void)removeObjectFromNotesAtIndex:(NSUInteger)theIndex; +- (void)removeNotesAtIndexes:(NSIndexSet *)theIndexes; - (void)removeAllObjectsFromNotes; @property (nonatomic, copy) NSArray<SKThumbnail *> *thumbnails; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 15:11:08 UTC (rev 15396) +++ trunk/SKMainWindowController.m 2025-06-07 16:04:20 UTC (rev 15397) @@ -965,20 +965,19 @@ return properties; } -- (void)addAnnotations:(NSArray *)notesToAdd removeAnnotations:(NSArray *)notesToRemove { +- (void)addAnnotations:(NSArray *)notesAndPagesToAdd removeAnnotations:(NSArray *)notesToRemove { PDFDocument *pdfDoc = [pdfView document]; NSMutableIndexSet *pageIndexes = [NSMutableIndexSet indexSet]; - NSMutableArray *added = [NSMutableArray array]; - NSMutableArray *removed = [NSMutableArray array]; - NSMutableArray *addedSkimNotes = [NSMutableArray array]; - NSMutableIndexSet *removedIndexes = [NSMutableIndexSet indexSet]; + NSMutableArray *addedNotes = [NSMutableArray array]; + NSMutableArray *removedNotesAndPages = [NSMutableArray array]; + NSMutableIndexSet *removedIndexes = [[notesToRemove firstObject] isSkimNote] ? [NSMutableIndexSet indexSet] : nil; mwcFlags.addOrRemoveNotesInBulk = 1; if ([notesToRemove count]) { for (PDFAnnotation *annotation in notesToRemove) { - [removed addObject:@[annotation, [annotation page]]]; - if ([annotation isSkimNote]) + [removedNotesAndPages addObject:@[annotation, [annotation page]]]; + if (removedIndexes) [removedIndexes addIndex:[notes indexOfObject:annotation]]; [pageIndexes addIndex:[annotation pageIndex]]; [pdfDoc removeAnnotation:annotation]; @@ -985,12 +984,10 @@ } } - if ([notesToAdd count]) { - for (NSArray *annotationAndPage in notesToAdd) { + if ([notesAndPagesToAdd count]) { + for (NSArray *annotationAndPage in notesAndPagesToAdd) { PDFAnnotation *annotation = [annotationAndPage firstObject]; - [added addObject:annotation]; - if ([annotation isSkimNote]) - [addedSkimNotes addObject:annotation]; + [addedNotes addObject:annotation]; [pageIndexes addIndex:[annotation pageIndex]]; [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; } @@ -998,12 +995,14 @@ mwcFlags.addOrRemoveNotesInBulk = 0; - [[[self undoManager] prepareWithInvocationTarget:self] addAnnotations:removed removeAnnotations:added]; + [[[self undoManager] prepareWithInvocationTarget:self] addAnnotations:removedNotesAndPages removeAnnotations:addedNotes]; + [removedIndexes removeIndex:NSNotFound]; + if ([removedIndexes count]) - [[self mutableArrayValueForKey:NOTES_KEY] removeObjectsAtIndexes:removedIndexes]; - if ([addedSkimNotes count]) - [self insertNotes:addedSkimNotes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([notes count], [addedSkimNotes count])]]; + [self removeNotesAtIndexes:removedIndexes]; + if ([[addedNotes firstObject] isSkimNote]) + [self insertNotes:addedNotes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([addedNotes count], [addedNotes count])]]; // make sure we clear the undo handling undoGroupOldPropertiesPerNote = nil; @@ -1017,18 +1016,16 @@ [pdfView resetPDFToolTipRects]; } -- (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts toDocument:(PDFDocument *)pdfDoc pageIndexes:(NSMutableIndexSet *)pageIndexes autoUpdate:(BOOL)autoUpdate { - NSMutableArray *notesToAdd = [NSMutableArray array]; +- (NSArray *)annotationsAndPagesFromDictionaries:(NSArray *)noteDicts forDocument:(PDFDocument *)pdfDoc autoUpdate:(BOOL)autoUpdate widgetDictionaries:(NSMutableArray *)widgetDicts { + NSMutableArray *notesAndPagesToAdd = [NSMutableArray array]; BOOL shouldDisplay = [pdfView hideNotes] == NO; - // disable automatic add/remove from the notification handlers - // we want to do this in bulk as binding can be very slow and there are potentially many notes - mwcFlags.addOrRemoveNotesInBulk = 1; - - // create new annotations from the dictionary and add them to their page and to the document + // create new annotations from the dictionary and get the page to add to for (NSDictionary *dict in noteDicts) { - if ([[dict objectForKey:SKNPDFAnnotationTypeKey] isEqualToString:SKNWidgetString]) + if ([[dict objectForKey:SKNPDFAnnotationTypeKey] isEqualToString:SKNWidgetString]) { + [widgetDicts addObject:dict]; continue; + } @autoreleasepool{ PDFAnnotation *annotation = [PDFAnnotation newSkimNoteWithProperties:dict]; if (annotation) { @@ -1037,59 +1034,43 @@ pageIndex = 0; else if (pageIndex >= [pdfDoc pageCount]) pageIndex = [pdfDoc pageCount] - 1; - [pageIndexes addIndex:pageIndex]; [annotation setShouldDisplay:shouldDisplay]; [annotation setShouldPrint:shouldDisplay]; PDFPage *page = [pdfDoc pageAtIndex:pageIndex]; if (autoUpdate && [[annotation contents] length] == 0) [annotation autoUpdateStringWithPage:page]; - [pdfDoc addAnnotation:annotation toPage:page]; - [notesToAdd addObject:annotation]; + [notesAndPagesToAdd addObject:@[annotation, page]]; } } } - mwcFlags.addOrRemoveNotesInBulk = 0; - - if ([notesToAdd count] > 0) - [self insertNotes:notesToAdd atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([notes count], [notesToAdd count])]]; + return notesAndPagesToAdd; } - (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { + // notesToRemove is either [self notes], nil, or non Skim notes BOOL isAddOrReplace = [notesToRemove count] == 0 || [[notesToRemove firstObject] isSkimNote]; PDFDocument *pdfDoc = [pdfView document]; - NSMutableIndexSet *pageIndexes = [NSMutableIndexSet indexSet]; + NSMutableArray *widgetDicts = [NSMutableArray array]; - if ([notesToRemove count]) { - // notesToRemove is either [self notes], nil, or non Skim notes - if (isAddOrReplace) { - [pdfView removePDFToolTipRects]; - // remove the current annotations - [pdfView setCurrentAnnotation:nil]; - } - mwcFlags.addOrRemoveNotesInBulk = 1; - for (PDFAnnotation *annotation in [notesToRemove copy]) { - [pageIndexes addIndex:[annotation pageIndex]]; - [pdfDoc removeAnnotation:annotation]; - } - mwcFlags.addOrRemoveNotesInBulk = 0; - if (isAddOrReplace) - [self removeAllObjectsFromNotes]; + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:isAddOrReplace == NO widgetDictionaries:widgetDicts]; + + if ([notesToRemove count] && isAddOrReplace) { + [pdfView removePDFToolTipRects]; + // remove the current annotations + [pdfView setCurrentAnnotation:nil]; } - if (notesToRemove && isAddOrReplace && [widgets count]) { - for (PDFAnnotation *widget in widgets) { - id origValue = [widgetValues objectForKey:widget]; - if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) - [widget setObjectValue:origValue]; - } - } - [self addAnnotationsFromDictionaries:noteDicts toDocument:pdfDoc pageIndexes:pageIndexes autoUpdate:isAddOrReplace == NO]; - if (isAddOrReplace) { - NSArray *widgetProperties = [noteDicts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type = \"Widget\""]]; - if ([widgetProperties count]) - [self changeWidgetsFromDictionaries:widgetProperties]; + if (notesToRemove && [widgets count]) { + for (PDFAnnotation *widget in widgets) { + id origValue = [widgetValues objectForKey:widget]; + if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) + [widget setObjectValue:origValue]; + } + } + if ([widgetDicts count]) + [self changeWidgetsFromDictionaries:widgetDicts]; } else if ([widgets count]) { NSMapTable *values = [NSMapTable strongToStrongObjectsMapTable]; for (PDFAnnotation *widget in widgets) @@ -1098,16 +1079,7 @@ [self setWidgetValues:values]; } - // make sure we clear the undo handling - undoGroupOldPropertiesPerNote = nil; - [rightSideController.noteArrayController rearrangeObjects]; // doesn't seem to be done automatically - [rightSideController.noteOutlineView reloadData]; - [self updateThumbnailsAtPageIndexes:pageIndexes]; - for (SKSnapshotWindowController *wc in snapshots) { - if ([wc isPageInIndexesVisible:pageIndexes]) - [self snapshotNeedsUpdate:wc lowPriority:NO]; - } - [pdfView resetPDFToolTipRects]; + [self addAnnotations:notesAndPagesToAdd removeAnnotations:notesToRemove]; } - (void)setPdfDocument:(PDFDocument *)pdfDocument addAnnotationsFromDictionaries:(NSArray *)noteDicts { @@ -1185,7 +1157,18 @@ [self applyChangedCropBoxes:cropBoxes inDocument:pdfDocument]; } - [self addAnnotationsFromDictionaries:noteDicts toDocument:pdfDoc pageIndexes:nil autoUpdate:NO]; + if ([noteDicts count]) { + NSArray *notesAndPagesToAdd = [self annotationsAndPagesFromDictionaries:noteDicts forDocument:pdfDoc autoUpdate:NO widgetDictionaries:nil]; + NSMutableArray *addedNotes = [NSMutableArray array]; + + for (NSArray *annotationAndPage in notesAndPagesToAdd) { + PDFAnnotation *annotation = [annotationAndPage firstObject]; + [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; + [addedNotes addObject:annotation]; + } + + [self insertNotes:addedNotes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, [addedNotes count])]]; + } [pdfView setDocument:pdfDocument]; [pdfDocument setDelegate:self]; @@ -1419,6 +1402,23 @@ [notes removeObjectAtIndex:theIndex]; } +- (void)removeNotesAtIndexes:(NSIndexSet *)theIndexes { + NSArray *removedNotes = [notes objectsAtIndexes:theIndexes]; + + for (PDFAnnotation *note in removedNotes) { + [[self windowControllerForNote:note] close]; + + if ([note hasNoteText]) + [rightSideController.noteOutlineView setRowHeight:0.0 forItem:[note noteText]]; + [rightSideController.noteOutlineView setRowHeight:0.0 forItem:note]; + } + + // Stop observing the removed notes + [self stopObservingNotes:removedNotes]; + + [notes removeObjectsAtIndexes:theIndexes]; +} + - (void)removeAllObjectsFromNotes { if ([notes count]) { NSArray *wcs = [[[self document] windowControllers] copy]; @@ -2254,9 +2254,9 @@ [self updateThumbnailAtPageIndex:[page pageIndex]]; [presentationView setNeedsDisplayForPage:page]; } else { - [[undoManager prepareWithInvocationTarget:[notification object]] removeAnnotation:annotation]; - if (mwcFlags.addOrRemoveNotesInBulk == 0) { + [[undoManager prepareWithInvocationTarget:[notification object]] removeAnnotation:annotation]; + if ([annotation isSkimNote]) { [annotation setShouldDisplay:[pdfView hideNotes] == NO]; [annotation setShouldPrint:[pdfView hideNotes] == NO]; @@ -2297,9 +2297,9 @@ [self updateThumbnailAtPageIndex:[page pageIndex]]; } } else { - [[undoManager prepareWithInvocationTarget:[notification object]] addAnnotation:annotation toPage:page]; - if (mwcFlags.addOrRemoveNotesInBulk == 0) { + [[undoManager prepareWithInvocationTarget:[notification object]] addAnnotation:annotation toPage:page]; + if ([annotation isSkimNote]) { if ([[self selectedNotes] containsObject:annotation]) [rightSideController.noteOutlineView deselectAll:self]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 15:11:09
|
Revision: 15396 http://sourceforge.net/p/skim-app/code/15396 Author: hofman Date: 2025-06-07 15:11:08 +0000 (Sat, 07 Jun 2025) Log Message: ----------- check whether popup is in annotations rather than checking page property, because the page property rremains after removal Modified Paths: -------------- trunk/PDFDocument_SKExtensions.m trunk/SKMainWindowController.m Modified: trunk/PDFDocument_SKExtensions.m =================================================================== --- trunk/PDFDocument_SKExtensions.m 2025-06-07 09:16:04 UTC (rev 15395) +++ trunk/PDFDocument_SKExtensions.m 2025-06-07 15:11:08 UTC (rev 15396) @@ -303,7 +303,7 @@ PDFAnnotation *popup = [annotation popup]; NSDictionary *userInfo = @{SKPDFDocumentAnnotationKey:annotation, SKPDFDocumentPageKey:page}; [page addAnnotation:annotation]; - if (popup && [popup page] == nil) + if (popup && [[page annotations] containsObject:popup] == NO) [page addAnnotation:popup]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentDidAddAnnotationNotification object:self userInfo:userInfo]; } @@ -314,7 +314,7 @@ NSDictionary *userInfo = @{SKPDFDocumentAnnotationKey:annotation, SKPDFDocumentPageKey:page}; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentWillRemoveAnnotationNotification object:self userInfo:userInfo]; [page removeAnnotation:annotation]; - if (popup && [popup page]) + if (popup && [[page annotations] containsObject:popup]) [page removeAnnotation:popup]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentDidRemoveAnnotationNotification object:self userInfo:userInfo]; } Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-07 09:16:04 UTC (rev 15395) +++ trunk/SKMainWindowController.m 2025-06-07 15:11:08 UTC (rev 15396) @@ -965,6 +965,58 @@ return properties; } +- (void)addAnnotations:(NSArray *)notesToAdd removeAnnotations:(NSArray *)notesToRemove { + PDFDocument *pdfDoc = [pdfView document]; + NSMutableIndexSet *pageIndexes = [NSMutableIndexSet indexSet]; + NSMutableArray *added = [NSMutableArray array]; + NSMutableArray *removed = [NSMutableArray array]; + NSMutableArray *addedSkimNotes = [NSMutableArray array]; + NSMutableIndexSet *removedIndexes = [NSMutableIndexSet indexSet]; + + mwcFlags.addOrRemoveNotesInBulk = 1; + + if ([notesToRemove count]) { + for (PDFAnnotation *annotation in notesToRemove) { + [removed addObject:@[annotation, [annotation page]]]; + if ([annotation isSkimNote]) + [removedIndexes addIndex:[notes indexOfObject:annotation]]; + [pageIndexes addIndex:[annotation pageIndex]]; + [pdfDoc removeAnnotation:annotation]; + } + } + + if ([notesToAdd count]) { + for (NSArray *annotationAndPage in notesToAdd) { + PDFAnnotation *annotation = [annotationAndPage firstObject]; + [added addObject:annotation]; + if ([annotation isSkimNote]) + [addedSkimNotes addObject:annotation]; + [pageIndexes addIndex:[annotation pageIndex]]; + [pdfDoc addAnnotation:annotation toPage:[annotationAndPage lastObject]]; + } + } + + mwcFlags.addOrRemoveNotesInBulk = 0; + + [[[self undoManager] prepareWithInvocationTarget:self] addAnnotations:removed removeAnnotations:added]; + + if ([removedIndexes count]) + [[self mutableArrayValueForKey:NOTES_KEY] removeObjectsAtIndexes:removedIndexes]; + if ([addedSkimNotes count]) + [self insertNotes:addedSkimNotes atIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange([notes count], [addedSkimNotes count])]]; + + // make sure we clear the undo handling + undoGroupOldPropertiesPerNote = nil; + [rightSideController.noteArrayController rearrangeObjects]; // doesn't seem to be done automatically + [rightSideController.noteOutlineView reloadData]; + [self updateThumbnailsAtPageIndexes:pageIndexes]; + for (SKSnapshotWindowController *wc in snapshots) { + if ([wc isPageInIndexesVisible:pageIndexes]) + [self snapshotNeedsUpdate:wc lowPriority:NO]; + } + [pdfView resetPDFToolTipRects]; +} + - (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts toDocument:(PDFDocument *)pdfDoc pageIndexes:(NSMutableIndexSet *)pageIndexes autoUpdate:(BOOL)autoUpdate { NSMutableArray *notesToAdd = [NSMutableArray array]; BOOL shouldDisplay = [pdfView hideNotes] == NO; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-07 09:16:06
|
Revision: 15395 http://sourceforge.net/p/skim-app/code/15395 Author: hofman Date: 2025-06-07 09:16:04 +0000 (Sat, 07 Jun 2025) Log Message: ----------- add or remove popup annotation implicitly when adding or removing parent, don't register popups in undo as they can be added implicitly by PDFKKit Modified Paths: -------------- trunk/PDFDocument_SKExtensions.m trunk/SKMainWindowController.m trunk/SKSnapshotWindowController.m Modified: trunk/PDFDocument_SKExtensions.m =================================================================== --- trunk/PDFDocument_SKExtensions.m 2025-06-06 22:28:49 UTC (rev 15394) +++ trunk/PDFDocument_SKExtensions.m 2025-06-07 09:16:04 UTC (rev 15395) @@ -300,16 +300,22 @@ - (NSArray *)detectedWidgets { return nil; } - (void)addAnnotation:(PDFAnnotation *)annotation toPage:(PDFPage *)page { + PDFAnnotation *popup = [annotation popup]; NSDictionary *userInfo = @{SKPDFDocumentAnnotationKey:annotation, SKPDFDocumentPageKey:page}; [page addAnnotation:annotation]; + if (popup && [popup page] == nil) + [page addAnnotation:popup]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentDidAddAnnotationNotification object:self userInfo:userInfo]; } - (void)removeAnnotation:(PDFAnnotation *)annotation { PDFPage *page = [annotation page]; + PDFAnnotation *popup = [annotation popup]; NSDictionary *userInfo = @{SKPDFDocumentAnnotationKey:annotation, SKPDFDocumentPageKey:page}; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentWillRemoveAnnotationNotification object:self userInfo:userInfo]; [page removeAnnotation:annotation]; + if (popup && [popup page]) + [page removeAnnotation:popup]; [[NSNotificationCenter defaultCenter] postNotificationName:SKPDFDocumentDidRemoveAnnotationNotification object:self userInfo:userInfo]; } Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-06 22:28:49 UTC (rev 15394) +++ trunk/SKMainWindowController.m 2025-06-07 09:16:04 UTC (rev 15395) @@ -1018,9 +1018,6 @@ mwcFlags.addOrRemoveNotesInBulk = 1; for (PDFAnnotation *annotation in [notesToRemove copy]) { [pageIndexes addIndex:[annotation pageIndex]]; - PDFAnnotation *popup = [annotation popup]; - if ([popup page]) - [pdfDoc removeAnnotation:popup]; [pdfDoc removeAnnotation:annotation]; } mwcFlags.addOrRemoveNotesInBulk = 0; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2025-06-06 22:28:49 UTC (rev 15394) +++ trunk/SKSnapshotWindowController.m 2025-06-07 09:16:04 UTC (rev 15395) @@ -187,17 +187,25 @@ } - (void)handleDidAddAnnotationNotification:(NSNotification *)notification { - PDFAnnotation *annotation = [[notification userInfo] objectForKey:SKPDFDocumentAnnotationKey]; PDFPage *page = [[notification userInfo] objectForKey:SKPDFDocumentPageKey]; - if ([self isPageVisible:page]) + if ([self isPageVisible:page]) { + PDFAnnotation *annotation = [[notification userInfo] objectForKey:SKPDFDocumentAnnotationKey]; + PDFAnnotation *popup = [annotation popup]; [pdfView addedAnnotation:annotation onPage:page]; + if (popup) + [pdfView addedAnnotation:popup onPage:page]; + } } - (void)handleDidRemoveAnnotationNotification:(NSNotification *)notification { - PDFAnnotation *annotation = [[notification userInfo] objectForKey:SKPDFDocumentAnnotationKey]; PDFPage *page = [[notification userInfo] objectForKey:SKPDFDocumentPageKey]; - if ([self isPageVisible:page]) + if ([self isPageVisible:page]) { + PDFAnnotation *annotation = [[notification userInfo] objectForKey:SKPDFDocumentAnnotationKey]; + PDFAnnotation *popup = [annotation popup]; [pdfView removedAnnotation:annotation onPage:page]; + if (popup) + [pdfView removedAnnotation:popup onPage:page]; + } } - (void)handleDidMoveAnnotationNotification:(NSNotification *)notification { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-06 22:28:52
|
Revision: 15394 http://sourceforge.net/p/skim-app/code/15394 Author: hofman Date: 2025-06-06 22:28:49 +0000 (Fri, 06 Jun 2025) Log Message: ----------- autoUpdateString for new annotations before adding to a page bby using a variant passing the page to add to Modified Paths: -------------- trunk/PDFAnnotationCircle_SKExtensions.m trunk/PDFAnnotationMarkup_SKExtensions.m trunk/PDFAnnotationSquare_SKExtensions.m trunk/PDFAnnotation_SKExtensions.h trunk/PDFAnnotation_SKExtensions.m trunk/SKMainWindowController.m trunk/SKPDFView.m Modified: trunk/PDFAnnotationCircle_SKExtensions.m =================================================================== --- trunk/PDFAnnotationCircle_SKExtensions.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/PDFAnnotationCircle_SKExtensions.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -103,8 +103,8 @@ return dx * dx + dy * dy >= 1.0; } -- (void)autoUpdateString { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) +- (void)autoUpdateStringWithPage:(PDFPage *)page { + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] || page == nil) return; // this calculation is roughly the inverse of -[PDFView addAnnotationWithType:context:] NSRect bounds = NSInsetRect([self bounds], [self lineWidth] - 1.0, [self lineWidth] - 1.0); @@ -113,7 +113,7 @@ return; t = 0.5 * w * h * (w + h - sqrt(2.0 * w * h)) / (w * w + h * h); bounds = NSInsetRect(bounds, t, t); - NSString *selString = [[[self page] selectionForRect:bounds] cleanedString]; + NSString *selString = [[page selectionForRect:bounds] cleanedString]; if ([selString length]) [self setString:selString]; } Modified: trunk/PDFAnnotationMarkup_SKExtensions.m =================================================================== --- trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/PDFAnnotationMarkup_SKExtensions.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -199,7 +199,7 @@ return lineRects; } -- (PDFSelection *)selection { +- (PDFSelection *)selectionWithPage:(PDFPage *)page { NSMutableArray *selections = [NSMutableArray array]; NSPointerArray *lines = [self lineRects]; NSUInteger i, iMax = [lines count]; @@ -206,7 +206,7 @@ for (i = 0; i < iMax; i++) { // slightly outset the rect to avoid rounding errors, as selectionForRect is pretty strict in some OS versions, but unfortunately not in others - PDFSelection *selection = [[self page] selectionForRect:NSInsetRect([lines rectAtIndex:i], -1.0, -1.0)]; + PDFSelection *selection = [page selectionForRect:NSInsetRect([lines rectAtIndex:i], -1.0, -1.0)]; if ([selection hasCharacters]) [selections addObject:selection]; } @@ -213,6 +213,10 @@ return [PDFSelection selectionByAddingSelections:selections]; } +- (PDFSelection *)selection { + return [self selectionWithPage:[self page]]; +} + - (BOOL)hitTest:(NSPoint)point { if ([super hitTest:point] == NO) return NO; @@ -303,6 +307,14 @@ [self setString:selString]; } +- (void)autoUpdateStringWithPage:(PDFPage *)page { + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) + return; + NSString *selString = [[self selectionWithPage:page] cleanedString]; + if ([selString length]) + [self setString:selString]; +} + - (NSSet *)keysForValuesToObserveForUndo { static NSSet *markupKeys = nil; if (markupKeys == nil) { Modified: trunk/PDFAnnotationSquare_SKExtensions.m =================================================================== --- trunk/PDFAnnotationSquare_SKExtensions.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/PDFAnnotationSquare_SKExtensions.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -93,13 +93,13 @@ return NSWidth(bounds) <= 2.0 * delta || NSHeight(bounds) <= 2.0 * delta || NSPointInRect(point, NSInsetRect(bounds, delta, delta)) == NO; } -- (void)autoUpdateString { - if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey]) +- (void)autoUpdateStringWithPage:(PDFPage *)page { + if ([[NSUserDefaults standardUserDefaults] boolForKey:SKDisableUpdateContentsFromEnclosedTextKey] || page == nil) return; NSRect bounds = NSInsetRect([self bounds], [self lineWidth] - 1.0, [self lineWidth] - 1.0); if (NSWidth(bounds) <= 0.0 || NSHeight(bounds) <= 0.0) return; - NSString *selString = [[[self page] selectionForRect:bounds] cleanedString]; + NSString *selString = [[page selectionForRect:bounds] cleanedString]; if ([selString length]) [self setString:selString]; } Modified: trunk/PDFAnnotation_SKExtensions.h =================================================================== --- trunk/PDFAnnotation_SKExtensions.h 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/PDFAnnotation_SKExtensions.h 2025-06-06 22:28:49 UTC (rev 15394) @@ -125,6 +125,7 @@ - (void)registerUserName; - (void)autoUpdateString; +- (void)autoUpdateStringWithPage:(PDFPage *)page; @property (nonatomic, readonly) NSString *uniqueID; Modified: trunk/PDFAnnotation_SKExtensions.m =================================================================== --- trunk/PDFAnnotation_SKExtensions.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/PDFAnnotation_SKExtensions.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -505,7 +505,8 @@ [self setModificationDate:[NSDate date]]; } -- (void)autoUpdateString {} +- (void)autoUpdateString { if ([self page]) [self autoUpdateStringWithPage:[self page]]; } +- (void)autoUpdateStringWithPage:(PDFPage *)page {} - (NSString *)colorDefaultKey { return nil; } Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/SKMainWindowController.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -988,9 +988,10 @@ [pageIndexes addIndex:pageIndex]; [annotation setShouldDisplay:shouldDisplay]; [annotation setShouldPrint:shouldDisplay]; - [pdfDoc addAnnotation:annotation toPage:[pdfDoc pageAtIndex:pageIndex]]; + PDFPage *page = [pdfDoc pageAtIndex:pageIndex]; if (autoUpdate && [[annotation contents] length] == 0) - [annotation autoUpdateString]; + [annotation autoUpdateStringWithPage:page]; + [pdfDoc addAnnotation:annotation toPage:page]; [notesToAdd addObject:annotation]; } } Modified: trunk/SKPDFView.m =================================================================== --- trunk/SKPDFView.m 2025-06-06 21:44:13 UTC (rev 15393) +++ trunk/SKPDFView.m 2025-06-06 22:28:49 UTC (rev 15394) @@ -2460,9 +2460,9 @@ if ([text length] > 0 || [newAnnotation string] == nil) [newAnnotation setString:text ?: @""]; [newAnnotation registerUserName]; + if ([text length] == 0 && isInitial == NO) + [newAnnotation autoUpdateStringWithPage:page]; [[self document] addAnnotation:newAnnotation toPage:page]; - if ([text length] == 0 && isInitial == NO) - [newAnnotation autoUpdateString]; } [self setUndoActionName:NSLocalizedString(@"Add Note", @"Undo action name")]; @@ -2476,11 +2476,11 @@ if (annotationType != SKNoteTypeLine && annotationType != SKNoteTypeInk && [text length] > 0) [newAnnotation setString:text]; [newAnnotation registerUserName]; - [[self document] addAnnotation:newAnnotation toPage:page]; if ([text length] == 0 && isInitial == NO) - [newAnnotation autoUpdateString]; + [newAnnotation autoUpdateStringWithPage:page]; if ([newAnnotation string] == nil) [newAnnotation setString:@""]; + [[self document] addAnnotation:newAnnotation toPage:page]; [self setUndoActionName:NSLocalizedString(@"Add Note", @"Undo action name")]; if (toolMode == SKToolModeText || toolMode == SKToolModeNote) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-06 21:44:16
|
Revision: 15393 http://sourceforge.net/p/skim-app/code/15393 Author: hofman Date: 2025-06-06 21:44:13 +0000 (Fri, 06 Jun 2025) Log Message: ----------- check page indexes directly Modified Paths: -------------- trunk/PDFView_SKExtensions.h trunk/PDFView_SKExtensions.m trunk/SKMainWindowController.m trunk/SKSnapshotWindowController.h trunk/SKSnapshotWindowController.m Modified: trunk/PDFView_SKExtensions.h =================================================================== --- trunk/PDFView_SKExtensions.h 2025-06-06 21:37:03 UTC (rev 15392) +++ trunk/PDFView_SKExtensions.h 2025-06-06 21:44:13 UTC (rev 15393) @@ -55,6 +55,7 @@ @property (nonatomic, readonly) NSRect visibleContentRect; - (BOOL)isPageAtIndexDisplayed:(NSUInteger)pageIndex; +- (BOOL)isPageAtIndexesDisplayed:(NSIndexSet *)pageIndexes; - (void)updatedAnnotation:(PDFAnnotation *)annotation; - (void)addedAnnotation:(PDFAnnotation *)annotation onPage:(PDFPage *)page; Modified: trunk/PDFView_SKExtensions.m =================================================================== --- trunk/PDFView_SKExtensions.m 2025-06-06 21:37:03 UTC (rev 15392) +++ trunk/PDFView_SKExtensions.m 2025-06-06 21:44:13 UTC (rev 15393) @@ -255,6 +255,10 @@ return NSLocationInRange(pageIndex, [self displayedPageIndexRange]); } +- (BOOL)isPageAtIndexesDisplayed:(NSIndexSet *)pageIndexes { + return [pageIndexes intersectsIndexesInRange:[self displayedPageIndexRange]]; +} + - (NSArray *)displayedPages { NSMutableArray *displayedPages = [NSMutableArray array]; PDFDocument *pdfDoc = [self document]; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-06 21:37:03 UTC (rev 15392) +++ trunk/SKMainWindowController.m 2025-06-06 21:44:13 UTC (rev 15393) @@ -1054,13 +1054,8 @@ [rightSideController.noteOutlineView reloadData]; [self updateThumbnailsAtPageIndexes:pageIndexes]; for (SKSnapshotWindowController *wc in snapshots) { - [pageIndexes enumerateIndexesUsingBlock:^(NSUInteger i, BOOL *stop){ - PDFPage *page = [pdfDoc pageAtIndex:i]; - if ([wc isPageVisible:page]) { - [self snapshotNeedsUpdate:wc lowPriority:NO]; - *stop = YES; - } - }]; + if ([wc isPageInIndexesVisible:pageIndexes]) + [self snapshotNeedsUpdate:wc lowPriority:NO]; } [pdfView resetPDFToolTipRects]; } Modified: trunk/SKSnapshotWindowController.h =================================================================== --- trunk/SKSnapshotWindowController.h 2025-06-06 21:37:03 UTC (rev 15392) +++ trunk/SKSnapshotWindowController.h 2025-06-06 21:44:13 UTC (rev 15393) @@ -84,6 +84,7 @@ - (void)setPdfDocument:(PDFDocument *)pdfDocument previewPageNumber:(NSInteger)pageNum displayOnScreen:(nullable NSScreen *)screen; - (BOOL)isPageVisible:(PDFPage *)page; +- (BOOL)isPageInIndexesVisible:(NSIndexSet *)pageIndexes; - (void)updatePageLabel; Modified: trunk/SKSnapshotWindowController.m =================================================================== --- trunk/SKSnapshotWindowController.m 2025-06-06 21:37:03 UTC (rev 15392) +++ trunk/SKSnapshotWindowController.m 2025-06-06 21:44:13 UTC (rev 15393) @@ -367,6 +367,10 @@ return [[page document] isEqual:[pdfView document]] && [pdfView isPageAtIndexDisplayed:[page pageIndex]]; } +- (BOOL)isPageInIndexesVisible:(NSIndexSet *)pageIndexes { + return [pdfView isPageAtIndexesDisplayed:pageIndexes]; +} + #pragma mark Acessors - (NSRect)bounds { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ho...@us...> - 2025-06-06 21:37:05
|
Revision: 15392 http://sourceforge.net/p/skim-app/code/15392 Author: hofman Date: 2025-06-06 21:37:03 +0000 (Fri, 06 Jun 2025) Log Message: ----------- use inverted boolean variable Modified Paths: -------------- trunk/SKMainWindowController.m Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2025-06-06 21:33:50 UTC (rev 15391) +++ trunk/SKMainWindowController.m 2025-06-06 21:37:03 UTC (rev 15392) @@ -1003,13 +1003,13 @@ } - (void)addAnnotationsFromDictionaries:(NSArray *)noteDicts removeAnnotations:(NSArray *)notesToRemove { - BOOL isConvert = [notesToRemove count] > 0 && [[notesToRemove firstObject] isSkimNote] == NO; + BOOL isAddOrReplace = [notesToRemove count] == 0 || [[notesToRemove firstObject] isSkimNote]; PDFDocument *pdfDoc = [pdfView document]; NSMutableIndexSet *pageIndexes = [NSMutableIndexSet indexSet]; if ([notesToRemove count]) { // notesToRemove is either [self notes], nil, or non Skim notes - if (isConvert == NO) { + if (isAddOrReplace) { [pdfView removePDFToolTipRects]; // remove the current annotations [pdfView setCurrentAnnotation:nil]; @@ -1023,10 +1023,10 @@ [pdfDoc removeAnnotation:annotation]; } mwcFlags.addOrRemoveNotesInBulk = 0; - if (isConvert == NO) + if (isAddOrReplace) [self removeAllObjectsFromNotes]; } - if (notesToRemove && isConvert == NO && [widgets count]) { + if (notesToRemove && isAddOrReplace && [widgets count]) { for (PDFAnnotation *widget in widgets) { id origValue = [widgetValues objectForKey:widget]; if ([([widget objectValue] ?: @"") isEqual:(origValue ?: @"")] == NO) @@ -1034,9 +1034,9 @@ } } - [self addAnnotationsFromDictionaries:noteDicts toDocument:pdfDoc pageIndexes:pageIndexes autoUpdate:isConvert]; + [self addAnnotationsFromDictionaries:noteDicts toDocument:pdfDoc pageIndexes:pageIndexes autoUpdate:isAddOrReplace == NO]; - if (isConvert == NO) { + if (isAddOrReplace) { NSArray *widgetProperties = [noteDicts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"type = \"Widget\""]]; if ([widgetProperties count]) [self changeWidgetsFromDictionaries:widgetProperties]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |