Revision: 12621 http://sourceforge.net/p/skim-app/code/12621 Author: hofman Date: 2021-12-13 15:22:31 +0000 (Mon, 13 Dec 2021) Log Message: ----------- Avoid parsing specifiers for selection twice when creating a new markup note for the document
Modified Paths: -------------- trunk/PDFPage_SKExtensions.m trunk/SKMainDocument.m Modified: trunk/PDFPage_SKExtensions.m =================================================================== --- trunk/PDFPage_SKExtensions.m 2021-12-12 10:30:54 UTC (rev 12620) +++ trunk/PDFPage_SKExtensions.m 2021-12-13 15:22:31 UTC (rev 12621) @@ -689,13 +689,13 @@ [[NSScriptCommand currentCommand] setScriptErrorString:@"PDF does not support notes."]; } else if ([type isEqualToString:SKNHighlightString] || [type isEqualToString:SKNStrikeOutString] || [type isEqualToString:SKNUnderlineString ]) { id selSpec = contentsValue ?: [[[[NSScriptCommand currentCommand] arguments] objectForKey:@"KeyDictionary"] objectForKey:SKPDFAnnotationSelectionSpecifierKey]; - PDFSelection *selection; + PDFSelection *selection = [selSpec isKindOfClass:[PDFSelection class]] ? selSpec : selSpec ? [PDFSelection selectionWithSpecifier:selSpec] : nil; NSInteger markupType = 0; [props removeObjectForKey:SKPDFAnnotationSelectionSpecifierKey]; if (selSpec == nil) { [[NSScriptCommand currentCommand] setScriptErrorNumber:NSRequiredArgumentsMissingScriptError]; [[NSScriptCommand currentCommand] setScriptErrorString:@"New markup notes need a selection."]; - } else if ((selection = [PDFSelection selectionWithSpecifier:selSpec])) { + } else if (selection) { if ([type isEqualToString:SKNHighlightString]) markupType = kPDFMarkupTypeHighlight; else if ([type isEqualToString:SKNUnderlineString]) Modified: trunk/SKMainDocument.m =================================================================== --- trunk/SKMainDocument.m 2021-12-12 10:30:54 UTC (rev 12620) +++ trunk/SKMainDocument.m 2021-12-13 15:22:31 UTC (rev 12621) @@ -1867,11 +1867,12 @@ if ([key isEqualToString:@"notes"]) { PDFAnnotation *annotation = nil; id selSpec = contentsValue ?: [[[[NSScriptCommand currentCommand] arguments] objectForKey:@"KeyDictionary"] objectForKey:SKPDFAnnotationSelectionSpecifierKey]; - PDFPage *page = selSpec ? [[PDFSelection selectionWithSpecifier:selSpec] safeFirstPage] : nil; + PDFSelection *sel = selSpec ? [PDFSelection selectionWithSpecifier:selSpec] : nil; + PDFPage *page = [sel safeFirstPage]; if (page == nil || [page document] != [self pdfDocument]) { [[NSScriptCommand currentCommand] setScriptErrorNumber:NSReceiversCantHandleCommandScriptError]; } else { - annotation = [page newScriptingObjectOfClass:class forValueForKey:key withContentsValue:contentsValue properties:properties]; + annotation = [page newScriptingObjectOfClass:class forValueForKey:key withContentsValue:sel ?: contentsValue properties:properties]; if ([annotation respondsToSelector:@selector(setPage:)]) [annotation performSelector:@selector(setPage:) withObject:page]; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit