Revision: 13277
http://sourceforge.net/p/skim-app/code/13277
Author: hofman
Date: 2023-02-02 14:57:37 +0000 (Thu, 02 Feb 2023)
Log Message:
-----------
Revert earlier commit, allow widgets as PDFAnnotation, observe objectValue for
nudo in this case. Most undo is implemented by PDFKit, and the only case we do
is using objectValue.
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.m
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2023-02-02 10:09:37 UTC (rev 13276)
+++ trunk/PDFAnnotation_SKExtensions.m 2023-02-02 14:57:37 UTC (rev 13277)
@@ -105,7 +105,7 @@
if ([[self type] isEqualToString:SKNWidgetString] && [self
respondsToSelector:@selector(valueForAnnotationKey:)])
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
- return [self valueForAnnotationKey:@"/NM"];
+ return [self valueForAnnotationKey:@"/T"];
#pragma clang diagnostic pop
return nil;
}
@@ -362,14 +362,64 @@
- (SKNoteText *)noteText { return nil; }
- (id)objectValue {
- return [self string];
+ if ([[self type] isEqualToString:SKNWidgetString]) {
+ if ([self widgetType] == kSKNPDFWidgetTypeButton) {
+ if ([self respondsToSelector:@selector(buttonWidgetState)])
+ return [NSNumber numberWithInteger:[self buttonWidgetState]];
+ else if ([self
respondsToSelector:@selector(valueForAnnotationKey:)])
+ return [NSNumber numberWithInteger:[[self
valueForAnnotationKey:@"/V"] isEqual:@"Off"] ? 0 : 1];
+ } else {
+ if ([self respondsToSelector:@selector(widgetStringValue)])
+ return [self widgetStringValue];
+ else if ([self
respondsToSelector:@selector(valueForAnnotationKey:)])
+ return [self valueForAnnotationKey:@"/V"];
+ }
+ return nil;
+ } else {
+ return [self string];
+ }
}
- (void)setObjectValue:(id)newObjectValue {
- [self setString:newObjectValue];
+ if ([[self type] isEqualToString:SKNWidgetString]) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ if ([self widgetType] == kSKNPDFWidgetTypeButton) {
+ if ([self respondsToSelector:@selector(setButtonWidgetState:)])
+ [self setButtonWidgetState:[newObjectValue integerValue]];
+ else if ([self
respondsToSelector:@selector(setValue:forAnnotationKey:)])
+ [self setValue:[newObjectValue integerValue] == 0 ? @"Off" :
@"Yes" forAnnotationKey:@"/V"];
+ } else {
+ if ([self respondsToSelector:@selector(setWidgetStringValue:)])
+ [self setWidgetStringValue:newObjectValue];
+ else if ([newObjectValue isKindOfClass:[NSString class]] && [self
respondsToSelector:@selector(setValue:forAnnotationKey:)])
+ [self setValue:newObjectValue forAnnotationKey:@"/V"];
+ else if ([self
respondsToSelector:@selector(removeValueForAnnotationKey:)])
+ [self removeValueForAnnotationKey:@"/V"];
+ }
+#pragma clang diagnostic pop
+ } else if ([newObjectValue isKindOfClass:[NSString class]]) {
+ [self setString:newObjectValue];
+ }
}
-- (SKNPDFWidgetType)widgetType { return kSKNPDFWidgetTypeUnknown; }
+- (SKNPDFWidgetType)widgetType {
+ if ([[self type] isEqualToString:SKNWidgetString]) {
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ if ([self respondsToSelector:@selector(valueForAnnotationKey:)]) {
+ NSString *ft = [self valueForAnnotationKey:@"/FT"];
+ if ([ft isEqualToString:@"/Tx"])
+ return kSKNPDFWidgetTypeText;
+ else if ([ft isEqualToString:@"/Btn"])
+ return kSKNPDFWidgetTypeButton;
+ else if ([ft isEqualToString:@"/Ch"])
+ return kSKNPDFWidgetTypeChoice;
+ }
+#pragma clang diagnostic pop
+ }
+ return kSKNPDFWidgetTypeUnknown;
+}
- (NSString *)textString { return nil; }
@@ -487,6 +537,8 @@
}
- (NSSet *)keysForValuesToObserveForUndo {
+ if ([[self type] isEqualToString:SKNWidgetString])
+ return [NSSet setWithObject:@"objectValue"];
static NSSet *keys = nil;
if (keys == nil)
keys = [[NSSet alloc] initWithObjects:SKNPDFAnnotationBoundsKey,
SKNPDFAnnotationStringKey, SKNPDFAnnotationColorKey, SKNPDFAnnotationBorderKey,
SKNPDFAnnotationModificationDateKey, SKNPDFAnnotationUserNameKey, 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