Revision: 16821
http://sourceforge.net/p/skim-app/code/16821
Author: hofman
Date: 2026-12-04 18:14:54 +0000 (Fri, 04 Dec 2026)
Log Message:
-----------
put placeholder pdfdocument and widget properties together
Modified Paths:
--------------
trunk/SKMainWindowController.h
trunk/SKMainWindowController.m
Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h 2026-12-04 17:25:49 UTC (rev 16820)
+++ trunk/SKMainWindowController.h 2026-12-04 18:14:54 UTC (rev 16821)
@@ -72,7 +72,7 @@
@class PDFAnnotation, PDFSelection, SKGroupedSearchResult;
@class SKSecondaryPDFView, SKPresentationView, SKStatusBar, SKFindController,
SKFieldEditor, SKOverviewView, SKSideWindow;
@class SKLeftSideViewController, SKRightSideViewController,
SKMainToolbarController, SKMainTouchBarController, SKNoteToolbarController,
SKProgressController, SKNoteTypeSheetController, SKSnapshotWindowController,
SKTransitionController;
-@class SKPresentationNotesAuxiliary;
+@class SKPresentationNotesAuxiliary, SKTemporaryData;
@interface SKMainWindowController : NSWindowController
<SKSnapshotWindowControllerDelegate, SKThumbnailDelegate,
SKFindControllerDelegate, SKPDFViewDelegate, SKPDFDocumentDelegate,
NSTouchBarDelegate, NSCollectionViewDataSource> {
NSSplitViewController *splitViewController;
@@ -161,8 +161,7 @@
NSMapTable<PDFAnnotation *, NSMutableDictionary *>
*undoGroupOldPropertiesPerNote;
- PDFDocument *placeholderPdfDocument;
- NSArray<NSDictionary<NSString *, id> *> *placeholderWidgetProperties;
+ SKTemporaryData *placeholder;
struct _mwcFlags {
unsigned int leftSidePaneState:1;
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2026-12-04 17:25:49 UTC (rev 16820)
+++ trunk/SKMainWindowController.m 2026-12-04 18:14:54 UTC (rev 16821)
@@ -107,6 +107,7 @@
#import "NSCharacterSet_SKExtensions.h"
#import "SKBookmark.h"
#import "SKApplication.h"
+#import "SKTemporaryData.h"
#define MULTIPLICATION_SIGN_CHARACTER (unichar)0x00d7
@@ -226,8 +227,8 @@
@implementation SKMainWindowController
-@synthesize statusBar, pdfView, secondaryPdfView, presentationNotesDocument,
presentationNotesOffset, notes, thumbnails, snapshots, searchResults,
groupedSearchResults, tags, rating, pageLabel, interactionMode,
placeholderPdfDocument;
-@dynamic pdfDocument, selectedNotes, hasNotes, widgetProperties, currentPage,
currentSetup, leftSidePaneState, rightSidePaneState, findPaneState,
displaysFindPane, leftSidePaneIsOpen, rightSidePaneIsOpen, leftSideWidth,
rightSideWidth, searchString, hasNoteToolbar, hasOverview, notesMenu;
+@synthesize statusBar, pdfView, secondaryPdfView, presentationNotesDocument,
presentationNotesOffset, notes, thumbnails, snapshots, searchResults,
groupedSearchResults, tags, rating, pageLabel, interactionMode;
+@dynamic pdfDocument, selectedNotes, hasNotes, widgetProperties, currentPage,
currentSetup, leftSidePaneState, rightSidePaneState, findPaneState,
displaysFindPane, leftSidePaneIsOpen, rightSidePaneIsOpen, leftSideWidth,
rightSideWidth, searchString, hasNoteToolbar, hasOverview, notesMenu,
placeholderPdfDocument;
+ (BOOL)automaticallyNotifiesObserversOfPageLabel { return NO; }
@@ -266,8 +267,7 @@
snapshotCacheSize = 0.0;
savedNormalSetup = [[NSMutableDictionary alloc] init];
- placeholderPdfDocument = nil;
- placeholderWidgetProperties = nil;
+ placeholder = nil;
pageLabel = nil;
markedPage = (SKDestination){NSNotFound, SKUnspecifiedPoint};
beforeMarkedPage = (SKDestination){NSNotFound, SKUnspecifiedPoint};
@@ -991,7 +991,10 @@
[self stopObservingNotes:widgets];
widgets = nil;
widgetValues = nil;
- placeholderWidgetProperties = nil;
+ if ([placeholder pdfDocument])
+ [placeholder setNoteDicts:nil];
+ else
+ placeholder = nil;
}
- (void)updateWidgetsWithProperties:(NSArray *)widgetDicts reset:(BOOL)reset {
@@ -1035,7 +1038,7 @@
- (NSArray *)widgetProperties {
if ([widgets count] == 0)
- return placeholderWidgetProperties ?: @[];
+ return [placeholder noteDicts] ?: @[];
NSMutableArray *properties = [NSMutableArray array];
for (PDFAnnotation *widget in widgets) {
if ([([widget objectValue] ?: @"") isEqual:([widgetValues
objectForKey:widget] ?: @"")] == NO)
@@ -1212,7 +1215,7 @@
[self removeAllObjectsFromNotes];
[self setThumbnails:@[]];
[self clearWidgets];
- placeholderPdfDocument = nil;
+ placeholder = nil;
// remember snapshots and close them, without animation
if ([snapshots count]) {
@@ -1258,10 +1261,13 @@
PDFDocument *pdfDoc = pdfDocument;
if ([pdfDoc allowsNotes] == NO) {
NSUInteger i, iMax = MIN(pageCount, [[noteDicts
valueForKeyPath:@"@max.pageIndex"] unsignedIntegerValue] + 1);
- pdfDoc = placeholderPdfDocument = [[SKPDFDocument alloc] init];
- [placeholderPdfDocument setContainingDocument:[self document]];
+ pdfDoc = [[SKPDFDocument alloc] init];
+ [pdfDoc setContainingDocument:[self document]];
for (i = 0; i < iMax; i++)
- [placeholderPdfDocument insertPage:[[SKPDFPage alloc] init]
atIndex:i];
+ [pdfDoc insertPage:[[SKPDFPage alloc] init] atIndex:i];
+ if (placeholder == nil)
+ placeholder = [[SKTemporaryData alloc] init];
+ [placeholder setPdfDocument:pdfDoc];
}
widgetProperties = [NSMutableArray array];
@@ -1288,7 +1294,7 @@
[self insertNotes:addedNotes atIndexes:[NSIndexSet
indexSetWithIndexesInRange:NSMakeRange(0, [addedNotes count])]];
} else {
- placeholderPdfDocument = nil;
+ [placeholder setPdfDocument:nil];
}
}
@@ -1301,10 +1307,15 @@
[self registerForDocumentNotifications];
- if (unlocked)
+ if (unlocked) {
[self updateWidgetsWithProperties:widgetProperties reset:NO];
- else if ([widgetProperties count])
- placeholderWidgetProperties = [widgetProperties copy];
+ if (placeholder && [placeholder pdfDocument] == nil)
+ placeholder = nil;
+ } else if ([widgetProperties count]) {
+ if (placeholder == nil)
+ placeholder = [[SKTemporaryData alloc] init];
+ [placeholder setNoteDicts:[widgetProperties copy]];
+ }
[self updatePageLabelsAndOutlineForExpansionState:openState];
@@ -1333,6 +1344,10 @@
return [pdfView document];
}
+- (PDFDocument *)placeholderPdfDocument{
+ return [placeholder pdfDocument];
+}
+
- (void)updatePageLabel {
NSString *label = [[pdfView currentPage] displayLabel];
if ([label isEqualToString:pageLabel] == NO) {
@@ -1471,7 +1486,7 @@
}
- (BOOL)hasNotes {
- if ([notes count] > 0 || [placeholderWidgetProperties count] > 0)
+ if ([notes count] > 0 || [[placeholder noteDicts] count] > 0)
return YES;
for (PDFAnnotation *widget in widgets) {
if ([([widget objectValue] ?: @"") isEqual:([widgetValues
objectForKey:widget] ?: @"")] == NO)
@@ -2205,7 +2220,7 @@
BOOL wasLocked = [[savedNormalSetup objectForKey:LOCKED_KEY] boolValue];
PDFDocument *pdfDoc = [pdfView document];
- if (placeholderPdfDocument && [pdfDoc allowsNotes]) {
+ if ([placeholder pdfDocument] && [pdfDoc allowsNotes]) {
NSMutableIndexSet *pageIndexes = wasLocked ? nil : [NSMutableIndexSet
indexSet];
for (PDFAnnotation *note in [self notes]) {
PDFPage *page = [note page];
@@ -2216,7 +2231,10 @@
[pageIndexes addIndex:pageIndex];
}
}
- placeholderPdfDocument = nil;
+ if ([placeholder noteDicts])
+ [placeholder setPdfDocument:nil];
+ else
+ placeholder = nil;
[rightSideController.noteArrayController rearrangeObjects];
if (wasLocked == NO) {
[rightSideController.noteOutlineView reloadData];
@@ -2225,12 +2243,15 @@
}
if (wasLocked) {
- if (placeholderWidgetProperties)
+ if ([placeholder noteDicts])
[[[self document] undoManager] disableUndoRegistration];
- [self updateWidgetsWithProperties:placeholderWidgetProperties
reset:NO];
- if (placeholderWidgetProperties)
+ [self updateWidgetsWithProperties:[placeholder noteDicts] reset:NO];
+ if ([placeholder noteDicts])
[[[self document] undoManager] enableUndoRegistration];
- placeholderWidgetProperties = nil;
+ if ([placeholder pdfDocument])
+ [placeholder setNoteDicts:nil];
+ else
+ placeholder = nil;
[self updatePageLabelsAndOutlineForExpansionState:nil];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit