Revision: 13322
http://sourceforge.net/p/skim-app/code/13322
Author: hofman
Date: 2023-03-01 10:28:18 +0000 (Wed, 01 Mar 2023)
Log Message:
-----------
use identical color component arras for plist data when passing colors as arrays
Modified Paths:
--------------
trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
trunk/SkimNotes/SKNUtilities.m
Modified: trunk/SkimNotes/PDFAnnotation_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/PDFAnnotation_SKNExtensions.m 2023-02-28 15:03:21 UTC
(rev 13321)
+++ trunk/SkimNotes/PDFAnnotation_SKNExtensions.m 2023-03-01 10:28:18 UTC
(rev 13322)
@@ -246,7 +246,9 @@
- (id)initSkimNoteWithBounds:(PDFRect)bounds forType:(NSString *)type {
if ([type hasPrefix:@"/"])
type = [type substringFromIndex:1];
+
#if defined(PDFKIT_PLATFORM_IOS)
+
if ([type isEqualToString:SKNNoteString] || [type
isEqualToString:SKNTextString]) {
if ([self isMemberOfClass:[PDFAnnotation class]]) {
// replace by our subclass
@@ -264,11 +266,10 @@
[self setShouldPrint:YES];
[self setSkimNote:YES];
[self setUserName:nil];
-
- if ([self respondsToSelector:@selector(setDefaultSkimNoteProperties)])
- [self setDefaultSkimNoteProperties];
}
+
#else
+
if ([self isMemberOfClass:[PDFAnnotation class]]) {
// generic, initalize the class for the type in the dictionary
@@ -280,29 +281,30 @@
#pragma clang diagnostic pop
self = [annotationClass alloc];
}
+
self = [self initSkimNoteWithBounds:bounds];
- if (self) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- if ([[self class] isSubclassOfClass:[PDFAnnotationMarkup class]]) {
+ if ([[self class] isSubclassOfClass:[PDFAnnotationMarkup class]]) {
#pragma clang diagnostic pop
- NSInteger markupType = kPDFMarkupTypeHighlight;
- if ([type isEqualToString:SKNUnderlineString] || [type
isEqualToString:SKNSquigglyString])
- markupType = kPDFMarkupTypeUnderline;
- else if ([type isEqualToString:SKNStrikeOutString])
- markupType = kPDFMarkupTypeStrikeOut;
- [(id)self setMarkupType:markupType];
- if ([[self class]
respondsToSelector:@selector(defaultSkimNoteColorForMarkupType:)]) {
- NSColor *color = [[self class]
defaultSkimNoteColorForMarkupType:markupType];
- if (color)
- [self setColor:color];
- }
+ NSInteger markupType = kPDFMarkupTypeHighlight;
+ if ([type isEqualToString:SKNUnderlineString] || [type
isEqualToString:SKNSquigglyString])
+ markupType = kPDFMarkupTypeUnderline;
+ else if ([type isEqualToString:SKNStrikeOutString])
+ markupType = kPDFMarkupTypeStrikeOut;
+ [(id)self setMarkupType:markupType];
+ if ([[self class]
respondsToSelector:@selector(defaultSkimNoteColorForMarkupType:)]) {
+ NSColor *color = [[self class]
defaultSkimNoteColorForMarkupType:markupType];
+ if (color)
+ [self setColor:color];
}
-
- if ([self respondsToSelector:@selector(setDefaultSkimNoteProperties)])
- [self setDefaultSkimNoteProperties];
}
+
#endif
+
+ if ([self respondsToSelector:@selector(setDefaultSkimNoteProperties)])
+ [self setDefaultSkimNoteProperties];
+
return self;
}
Modified: trunk/SkimNotes/SKNUtilities.m
===================================================================
--- trunk/SkimNotes/SKNUtilities.m 2023-02-28 15:03:21 UTC (rev 13321)
+++ trunk/SkimNotes/SKNUtilities.m 2023-03-01 10:28:18 UTC (rev 13322)
@@ -157,7 +157,7 @@
return YES;
}
-static NSArray *SKNCreateArrayFromColor(SKNColor *color, NSMapTable **colors) {
+static NSArray *SKNCreateArrayFromColor(SKNColor *color, NSMapTable **colors,
NSMutableSet **arrays) {
if ([color isKindOfClass:[SKNColor class]]) {
NSArray *array = [*colors objectForKey:color];
if (array == nil) {
@@ -195,7 +195,14 @@
}
return array;
} else if (SKNIsNumberArray(color)) {
- return [(NSArray *)color retain];
+ NSArray *array = [*arrays member:color];
+ if (array == nil) {
+ if (*arrays == nil)
+ *arrays = [[NSMutableSet alloc] init];
+ [*arrays addObject:color];
+ array = (NSArray *)color;
+ }
+ return [array retain];
} else {
return nil;
}
@@ -319,21 +326,22 @@
if (asPlist) {
NSMutableArray *array = [[NSMutableArray alloc] init];
NSMapTable *colors = nil;
+ NSMutableSet *arrays = nil;
for (NSDictionary *noteDict in noteDicts) {
NSMutableDictionary *dict = [noteDict mutableCopy];
id value;
if ((value = [dict objectForKey:NOTE_COLOR_KEY])) {
- value = SKNCreateArrayFromColor(value, &colors);
+ value = SKNCreateArrayFromColor(value, &colors, &arrays);
[dict setObject:value forKey:NOTE_COLOR_KEY];
[value release];
}
if ((value = [dict objectForKey:NOTE_INTERIOR_COLOR_KEY])) {
- value = SKNCreateArrayFromColor(value, &colors);
+ value = SKNCreateArrayFromColor(value, &colors, &arrays);
[dict setObject:value forKey:NOTE_INTERIOR_COLOR_KEY];
[value release];
}
if ((value = [dict objectForKey:NOTE_FONT_COLOR_KEY])) {
- value = SKNCreateArrayFromColor(value, &colors);
+ value = SKNCreateArrayFromColor(value, &colors, &arrays);
[dict setObject:value forKey:NOTE_FONT_COLOR_KEY];
[value release];
}
@@ -385,6 +393,7 @@
data = [NSPropertyListSerialization dataWithPropertyList:array
format:NSPropertyListBinaryFormat_v1_0 options:0 error:NULL];
[array release];
[colors release];
+ [arrays release];
} else {
data = [NSKeyedArchiver archivedDataWithRootObject:noteDicts];
}
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