-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathFPArchivalDictionaryUpgrader.m
More file actions
52 lines (45 loc) · 1.66 KB
/
FPArchivalDictionaryUpgrader.m
File metadata and controls
52 lines (45 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// FPArchivalDictionaryUpgrader.m
// FormulatePro
//
// Created by Andrew de los Reyes on 4/7/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import "FPArchivalDictionaryUpgrader.h"
@implementation FPArchivalDictionaryUpgrader
+ (int)currentVersion
{
return 3;
}
+ (NSDictionary *)upgradeDictionary:(NSDictionary*)dict
fromVersion:(int)old_version
{
NSMutableDictionary *ret = [dict mutableCopy];
// upgrade from 1 -> 2 if necessary
if (2 > old_version) {
// in version 1, drawsFill and drawsStroke were set to NO, but they
// were, in fact, drawn. here we change them to yes
if (([[dict objectForKey:@"Graphic Class"] isEqualToString:@"Rectangle"]) ||
([[dict objectForKey:@"Graphic Class"] isEqualToString:@"Rectangle"])) {
[ret setObject:[NSNumber numberWithBool:YES] forKey:@"drawsFill"];
[ret setObject:[NSNumber numberWithBool:YES] forKey:@"drawsStroke"];
}
}
// upgrade from 2 -> 3 if necessary
if (3 > old_version) {
// in versions 1 and 2, all graphics were sent to the printer.
// staring in version 3, there is a BOOL to decide if graphics
// get printed
[ret setObject:[NSNumber numberWithBool:NO] forKey:@"hideWhenPrinting"];
}
return ret;
}
+ (void)upgradeGraphicsInPlace:(NSMutableArray *)arr
fromVersion:(int)old_version
{
for (int i = 0; i < [arr count]; i++)
[arr replaceObjectAtIndex:i withObject:
[FPArchivalDictionaryUpgrader upgradeDictionary:[arr objectAtIndex:i]
fromVersion:old_version]];
}
@end