Browse Source

Merge branch 'develop_ocToSwift' of git.kdan.cc:Mac_PDF/PDF_Office into develop_ocToSwift

tangchao 1 year ago
parent
commit
9d45a752ae

+ 16 - 20
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -232,12 +232,6 @@
 		89E4E76429656A88002DBA6F /* KMAnnotationStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E75F29656A88002DBA6F /* KMAnnotationStampViewController.xib */; };
 		89E4E76529656A88002DBA6F /* KMAnnotationStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E75F29656A88002DBA6F /* KMAnnotationStampViewController.xib */; };
 		89E4E76629656A88002DBA6F /* KMAnnotationStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E75F29656A88002DBA6F /* KMAnnotationStampViewController.xib */; };
-		89E4E76E29657953002DBA6F /* KMStampManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E76D29657953002DBA6F /* KMStampManager.m */; };
-		89E4E76F29657953002DBA6F /* KMStampManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E76D29657953002DBA6F /* KMStampManager.m */; };
-		89E4E77029657953002DBA6F /* KMStampManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E76D29657953002DBA6F /* KMStampManager.m */; };
-		89E4E7792967B370002DBA6F /* KMDynamicStampViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E7772967B370002DBA6F /* KMDynamicStampViewController.m */; };
-		89E4E77A2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E7772967B370002DBA6F /* KMDynamicStampViewController.m */; };
-		89E4E77B2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 89E4E7772967B370002DBA6F /* KMDynamicStampViewController.m */; };
 		89E4E77C2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E7782967B370002DBA6F /* KMDynamicStampViewController.xib */; };
 		89E4E77D2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E7782967B370002DBA6F /* KMDynamicStampViewController.xib */; };
 		89E4E77E2967B370002DBA6F /* KMDynamicStampViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 89E4E7782967B370002DBA6F /* KMDynamicStampViewController.xib */; };
@@ -1216,6 +1210,12 @@
 		AD5999362AD7D9C200412F8B /* KMPropertiesViewPopController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999352AD7D9C200412F8B /* KMPropertiesViewPopController.swift */; };
 		AD5999372AD7D9C200412F8B /* KMPropertiesViewPopController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999352AD7D9C200412F8B /* KMPropertiesViewPopController.swift */; };
 		AD5999382AD7D9C200412F8B /* KMPropertiesViewPopController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999352AD7D9C200412F8B /* KMPropertiesViewPopController.swift */; };
+		AD59993E2AD7E88600412F8B /* KMStampManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD59993D2AD7E88600412F8B /* KMStampManager.swift */; };
+		AD59993F2AD7E88600412F8B /* KMStampManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD59993D2AD7E88600412F8B /* KMStampManager.swift */; };
+		AD5999402AD7E88600412F8B /* KMStampManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD59993D2AD7E88600412F8B /* KMStampManager.swift */; };
+		AD5999422AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999412AD8DC2000412F8B /* KMDynamicStampViewController.swift */; };
+		AD5999432AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999412AD8DC2000412F8B /* KMDynamicStampViewController.swift */; };
+		AD5999442AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD5999412AD8DC2000412F8B /* KMDynamicStampViewController.swift */; };
 		AD61B7AD2A9DC6F600D346C1 /* KMResourceDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD61B7AA2A9DC6F500D346C1 /* KMResourceDownloadManager.swift */; };
 		AD61B7AE2A9DD06C00D346C1 /* libDocumentAI.3.2.2.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AD8DD2922A972486007CC9D0 /* libDocumentAI.3.2.2.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
 		AD61B7AF2A9DD06F00D346C1 /* libonnxruntime.1.14.1.dylib in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = AD8DD2962A97248E007CC9D0 /* libonnxruntime.1.14.1.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
@@ -3574,10 +3574,6 @@
 		89E4E75E29656A88002DBA6F /* KMAnnotationStampViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMAnnotationStampViewController.m; sourceTree = "<group>"; };
 		89E4E75F29656A88002DBA6F /* KMAnnotationStampViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMAnnotationStampViewController.xib; sourceTree = "<group>"; };
 		89E4E76029656A88002DBA6F /* KMAnnotationStampViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMAnnotationStampViewController.h; sourceTree = "<group>"; };
-		89E4E76C29657953002DBA6F /* KMStampManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMStampManager.h; sourceTree = "<group>"; };
-		89E4E76D29657953002DBA6F /* KMStampManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KMStampManager.m; sourceTree = "<group>"; };
-		89E4E7762967B370002DBA6F /* KMDynamicStampViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMDynamicStampViewController.h; sourceTree = "<group>"; };
-		89E4E7772967B370002DBA6F /* KMDynamicStampViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMDynamicStampViewController.m; sourceTree = "<group>"; };
 		89E4E7782967B370002DBA6F /* KMDynamicStampViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMDynamicStampViewController.xib; sourceTree = "<group>"; };
 		89E4E77F2967BF5A002DBA6F /* KMCustomizeStampViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMCustomizeStampViewController.h; sourceTree = "<group>"; };
 		89E4E7802967BF5A002DBA6F /* KMCustomizeStampViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMCustomizeStampViewController.m; sourceTree = "<group>"; };
@@ -3961,6 +3957,8 @@
 		AD4B45702940B0000076FA14 /* KMOCRModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMOCRModel.swift; sourceTree = "<group>"; };
 		AD53B6FD29AC5FCD00D61E81 /* KMLightMemberToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMLightMemberToken.swift; sourceTree = "<group>"; };
 		AD5999352AD7D9C200412F8B /* KMPropertiesViewPopController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPropertiesViewPopController.swift; sourceTree = "<group>"; };
+		AD59993D2AD7E88600412F8B /* KMStampManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMStampManager.swift; sourceTree = "<group>"; };
+		AD5999412AD8DC2000412F8B /* KMDynamicStampViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMDynamicStampViewController.swift; sourceTree = "<group>"; };
 		AD61B7AA2A9DC6F500D346C1 /* KMResourceDownloadManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KMResourceDownloadManager.swift; sourceTree = "<group>"; };
 		AD6218D32A7D29F40088475C /* KMComparativeGradientView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KMComparativeGradientView.swift; sourceTree = "<group>"; };
 		AD62606D2A9D968A006C6413 /* KMEditPDFAssets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = KMEditPDFAssets.xcassets; sourceTree = "<group>"; };
@@ -5287,14 +5285,12 @@
 				89E4E76029656A88002DBA6F /* KMAnnotationStampViewController.h */,
 				89E4E75E29656A88002DBA6F /* KMAnnotationStampViewController.m */,
 				89E4E75F29656A88002DBA6F /* KMAnnotationStampViewController.xib */,
-				89E4E7762967B370002DBA6F /* KMDynamicStampViewController.h */,
-				89E4E7772967B370002DBA6F /* KMDynamicStampViewController.m */,
+				AD5999412AD8DC2000412F8B /* KMDynamicStampViewController.swift */,
 				89E4E7782967B370002DBA6F /* KMDynamicStampViewController.xib */,
 				89E4E77F2967BF5A002DBA6F /* KMCustomizeStampViewController.h */,
 				89E4E7802967BF5A002DBA6F /* KMCustomizeStampViewController.m */,
 				89E4E7812967BF5A002DBA6F /* KMCustomizeStampViewController.xib */,
-				89E4E76C29657953002DBA6F /* KMStampManager.h */,
-				89E4E76D29657953002DBA6F /* KMStampManager.m */,
+				AD59993D2AD7E88600412F8B /* KMStampManager.swift */,
 			);
 			path = StampList;
 			sourceTree = "<group>";
@@ -10420,6 +10416,7 @@
 				9F0201652A176AF200C9B673 /* KMDottedLineView.swift in Sources */,
 				BBBB6CDA2AD15B900035AA66 /* CPDFFreeTextAnnotation+PDFListView.swift in Sources */,
 				BB5DF1F12959C9F00025CDA1 /* KMHeaderFooterPropertyMainController.swift in Sources */,
+				AD5999422AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */,
 				BBC3482429559506008D2CD1 /* KMBackgroundManager.swift in Sources */,
 				AD867FC529DFFBC400F00440 /* KMAnnotationOutlineRowView.swift in Sources */,
 				BB4EEF2D29763EE7003A3537 /* KMRedactBaseWindowController.swift in Sources */,
@@ -10462,7 +10459,6 @@
 				89752DF62938A236003FF08E /* PublicKey.swift in Sources */,
 				89E4E73E2964160F002DBA6F /* KMAnnotationLinkViewController.m in Sources */,
 				BBC3480C29558DC1008D2CD1 /* KMBackgroundController.swift in Sources */,
-				89E4E7792967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				9FBC48B8299B44C600CA39D7 /* KMSecondaryViewController.m in Sources */,
 				BBC348142955920B008D2CD1 /* KMBackgroundPropertyController.swift in Sources */,
 				BBEC00D1295C33D600A26C98 /* KMCreateBatesController.swift in Sources */,
@@ -10586,6 +10582,7 @@
 				9F0CB5052986561E00007028 /* KMDesignToken+BorderRight.swift in Sources */,
 				AD0FA50A29A9E74200EDEB50 /* KMLoginInputPasswordView.swift in Sources */,
 				8942F80329262B2E00389627 /* KMSideViewController.swift in Sources */,
+				AD59993E2AD7E88600412F8B /* KMStampManager.swift in Sources */,
 				BB147014299DC0D100784A6A /* OIDAuthState.m in Sources */,
 				BB3AAB9029878CE000992A5A /* KMWatermarkAdjectivePropertyMainController.swift in Sources */,
 				BB147038299DC0D200784A6A /* OIDAuthorizationResponse.m in Sources */,
@@ -10832,7 +10829,6 @@
 				BB897220294AF9080045787C /* KMWatermarkAdjectiveTopBarView.swift in Sources */,
 				AD9527D32952D51A0039D2BC /* KMPrintPresenter.swift in Sources */,
 				ADEC7A7E299397F8009A8256 /* NSFont+SFProText.swift in Sources */,
-				89E4E76E29657953002DBA6F /* KMStampManager.m in Sources */,
 				9F221ECF29A85D3700978A59 /* KMDesignBase.swift in Sources */,
 				ADB2D6F9294882AE0029D2B3 /* KMTextFieldStepperView.swift in Sources */,
 				9F72D2082994BDAF00DCACF1 /* KMNotificationVC.swift in Sources */,
@@ -11187,6 +11183,7 @@
 				F37322F4292DF9410013862C /* CSelfSignAnnotationFreeText.m in Sources */,
 				ADCB98F729274B6B00B51A03 /* KMBatchProcessingTableView.swift in Sources */,
 				899700E028F3A9F2009AF911 /* KMHomeWindowController.swift in Sources */,
+				AD59993F2AD7E88600412F8B /* KMStampManager.swift in Sources */,
 				9F53D5502AD677A000CCF9D8 /* CPDFListViewConfig.swift in Sources */,
 				BB8F4548295A9CDC0037EA22 /* KMHeaderFooterListController.swift in Sources */,
 				9F0CB5022986560D00007028 /* KMDesignToken+BorderTop.swift in Sources */,
@@ -11271,7 +11268,6 @@
 				ADDEEA7B2AD3F4C800EF675D /* KMPopUpButton.swift in Sources */,
 				BBC3480D29558DC1008D2CD1 /* KMBackgroundController.swift in Sources */,
 				BB6DD8262934D056001F0544 /* KMSecureEncryptSuccessTipView.swift in Sources */,
-				89E4E77A2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				9FBC48B9299B44C600CA39D7 /* KMSecondaryViewController.m in Sources */,
 				BBC348152955920B008D2CD1 /* KMBackgroundPropertyController.swift in Sources */,
 				BBEC00D2295C33D600A26C98 /* KMCreateBatesController.swift in Sources */,
@@ -11432,6 +11428,7 @@
 				F37322F7292DF9410013862C /* CSelfSignAnnotation.m in Sources */,
 				9F1FE4D929406E4700E952CA /* NSString+Utils.m in Sources */,
 				BB146FE2299DC0D100784A6A /* GTLRDriveQuery.m in Sources */,
+				AD5999432AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */,
 				ADCB98CA2924741B00B51A03 /* KMBatchProcessingView.swift in Sources */,
 				BBD1F794296FE92500343885 /* KMPageEditSplitSettingView.swift in Sources */,
 				899700FF28F40710009AF911 /* KMBookMarkViewController.swift in Sources */,
@@ -11625,7 +11622,6 @@
 				BBEC00E2295C410A00A26C98 /* KMBatesPrefixInfoView.swift in Sources */,
 				9F1F82E42934D5240092C4B4 /* KMHomeExtractActionViewController.swift in Sources */,
 				ADEC7A7F299397F8009A8256 /* NSFont+SFProText.swift in Sources */,
-				89E4E76F29657953002DBA6F /* KMStampManager.m in Sources */,
 				9F221ED029A85D3700978A59 /* KMDesignBase.swift in Sources */,
 				BB74DA802AC42959006EDFE7 /* NSButton+KMExtension.swift in Sources */,
 				BB897221294AF9080045787C /* KMWatermarkAdjectiveTopBarView.swift in Sources */,
@@ -12396,7 +12392,6 @@
 				ADDEEA4B2AD38BDB00EF675D /* KMSignatureHelpViewController.swift in Sources */,
 				9FDD0F7E2952F2D8000C4DAD /* KMBaseParser.swift in Sources */,
 				9FCFEC7E2AC579F600EAD2CB /* CPDFListSignatureAnnotation.swift in Sources */,
-				89E4E77B2967B370002DBA6F /* KMDynamicStampViewController.m in Sources */,
 				BB8115FD29924A5F0008F536 /* KMSecureEncryptCheckCellView.swift in Sources */,
 				9F78EFBD28F7C1CC001E66F4 /* KMHomeViewController.swift in Sources */,
 				9FCFEC9A2AD14EEF00EAD2CB /* KMMailHelper.swift in Sources */,
@@ -12464,7 +12459,7 @@
 				BB897267294C724D0045787C /* KMWatermarkAdjectiveOutsideView.swift in Sources */,
 				AD9527EC2955520C0039D2BC /* KMBaseTextFieldModel.swift in Sources */,
 				BBF38A5C294F2B760086D025 /* KMWatermarkPositionView.swift in Sources */,
-				89E4E77029657953002DBA6F /* KMStampManager.m in Sources */,
+				AD5999402AD7E88600412F8B /* KMStampManager.swift in Sources */,
 				BB7BC4DA2AD3D6B700D6BEE6 /* PDFListView+KMExtensions.swift in Sources */,
 				BB14702E299DC0D100784A6A /* OIDEndSessionRequest.m in Sources */,
 				BB146FE3299DC0D100784A6A /* GTLRDriveQuery.m in Sources */,
@@ -12596,6 +12591,7 @@
 				BB146FCB299DC0D100784A6A /* GTMSessionFetcher.m in Sources */,
 				9F0CB4CF298654FA00007028 /* KMDesignToken+Height.swift in Sources */,
 				ADA08A8C29F21A53009B2A7B /* KMPDFViewAnnotationOnceModeStore.swift in Sources */,
+				AD5999442AD8DC2000412F8B /* KMDynamicStampViewController.swift in Sources */,
 				BBC347FF295448DE008D2CD1 /* KMWatermarkTemplateModel.swift in Sources */,
 				BBD7FE042A13218F00F96075 /* KMWatermarkAdjectivePropertyBaseController.swift in Sources */,
 				89752DA12936EC50003FF08E /* KMToolbar.m in Sources */,

+ 3 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.m

@@ -6,9 +6,7 @@
 //
 
 #import "KMAnnotationStampViewController.h"
-#import "KMStampManager.h"
 #import "KMCustomizeStampViewController.h"
-#import "KMDynamicStampViewController.h"
 #import <PDF_Master-Swift.h>
 
 #pragma mark - KMStampTableRowView
@@ -288,8 +286,8 @@
     } else if (self.currentType == 4/*CPDFStampTypeDynamic*/) {
             KMDynamicStampViewController *vc = [[KMDynamicStampViewController alloc] init];
             vc.callBack = ^{
-                [[[KMStampManager defaultManager] stamps] removeObjectsInArray:blockSelf.stampLists];
-                [[[KMStampManager defaultManager] stamps] addObjectsFromArray:[[KMStampManager defaultManager] dynamicStamps]];
+                [[KMStampManager defaultManager] removeStampsWithArray:blockSelf.stampLists];
+                [[KMStampManager defaultManager] addStampsWithArray:[[KMStampManager defaultManager] dynamicStamps]];
                 [blockSelf reloadStampData:blockSelf.currentType];
             };
             [self presentViewControllerAsModalWindow:vc]; 
@@ -419,7 +417,7 @@
 }
 
 - (void)deleteAllCustomizeStamp {
-    [[[KMStampManager defaultManager] stamps] removeObjectsInArray:self.stampLists];
+    [[KMStampManager defaultManager] removeStampsWithArray:self.stampLists];
     [self reloadStampData:self.currentType];
 }
 

+ 0 - 17
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMDynamicStampViewController.h

@@ -1,17 +0,0 @@
-//
-//  KMDynamicStampViewController.h
-//  PDF Master
-//
-//  Created by lxy on 2023/1/6.
-//
-
-#import <Cocoa/Cocoa.h>
-
-typedef void(^updateStampCallBack)(void);
-
-@interface KMDynamicStampViewController : NSViewController
-
-@property(nonatomic,copy) updateStampCallBack callBack;
-
-@end
-

+ 0 - 143
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMDynamicStampViewController.m

@@ -1,143 +0,0 @@
-//
-//  KMDynamicStampViewController.m
-//  PDF Master
-//
-//  Created by lxy on 2023/1/6.
-//
-
-#import "KMDynamicStampViewController.h"
-#import "KMStampManager.h"
-
-@interface KMDynamicStampViewController ()<NSComboBoxDelegate>
-@property (weak) IBOutlet NSTextField *titleTextField;
-@property (weak) IBOutlet NSImageView *preViewImageView;
-@property (weak) IBOutlet NSButton *authorButton;
-@property (weak) IBOutlet NSTextField *authorTextField;
-@property (weak) IBOutlet NSTextField *timeTextField;
-@property (weak) IBOutlet KMComboBox *showTimeBox;
-@property (weak) IBOutlet NSButton *okButton;
-@property (weak) IBOutlet NSButton *cancel;
-@property (nonatomic,copy) NSArray *dateStyleArray;
-@property (nonatomic,copy) NSString *dateFormatterString;
-@property (nonatomic,assign) BOOL dynamicStampNeedsAuthor;
-
-@end
-
-@implementation KMDynamicStampViewController
-
-- (void)viewDidAppear {
-    [super viewDidAppear];
-    self.view.window.title = @"";
-    self.view.window.styleMask = self.view.window.styleMask | NSWindowStyleMaskFullSizeContentView;
-    self.view.window.titlebarAppearsTransparent = YES;
-    [[self.view.window standardWindowButton:NSWindowCloseButton] setHidden:YES];
-    [[self.view.window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
-    [[self.view.window standardWindowButton:NSWindowZoomButton] setHidden:YES];
-}
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    self.titleTextField.stringValue = NSLocalizedString(@"DynamicStamp", nil);
-    [self.authorButton setTitle:NSLocalizedString(@"author", nil)];
-    self.timeTextField.stringValue = NSLocalizedString(@"Time", nil);
-    
-    self.dateStyleArray = [[KMStampManager defaultManager] dateStyleArray];
-    [self.showTimeBox removeAllItems];
-    [self.showTimeBox addItemsWithObjectValues:self.dateStyleArray];
-    self.showTimeBox.delegate = self;
-    
-    //从沙盒中取出日期格式
-    NSString *dateStyleIndicate = [[NSUserDefaults standardUserDefaults] objectForKey:CPDFDynamicStampDateStyleKey1];
-    if (dateStyleIndicate.length < 1) {
-        [self.showTimeBox selectItemAtIndex:self.dateStyleArray.count - 1];
-        self.dateFormatterString = self.dateStyleArray.lastObject;
-    } else {
-        NSInteger index = [self.dateStyleArray indexOfObject:dateStyleIndicate];
-        if (index > self.dateStyleArray.count) {
-            [self.showTimeBox selectItemAtIndex:self.dateStyleArray.count - 1];
-            self.dateFormatterString = self.dateStyleArray.lastObject;
-        }else{
-            [self.showTimeBox selectItemAtIndex:index];
-            self.dateFormatterString = dateStyleIndicate;
-        }
-    }
-    
-    //从沙盒中取出是否需要作者
-    BOOL isNeedAuthor = [[NSUserDefaults standardUserDefaults] boolForKey:CPDFDynamicStampNeedAuthorKey1];
-    
-    self.dynamicStampNeedsAuthor = !isNeedAuthor;
-    [self.authorButton setState:self.dynamicStampNeedsAuthor];
-    
-    NSString *author = [[NSUserDefaults standardUserDefaults] stringForKey:@"CKUserName"];
-    author = [author length] ? author : NSFullUserName();
-   
-    if(self.dynamicStampNeedsAuthor){
-        self.authorTextField.editable = YES;
-        self.authorTextField.selectable = YES;
-        self.authorTextField.stringValue = author;
-        [self.authorTextField.cell setPlaceholderString:@""];
-        self.authorTextField.delegate = self;
-    } else {
-        self.authorTextField.editable = NO;
-        self.authorTextField.selectable = NO;
-        self.authorTextField.stringValue = @"";
-        [self.authorTextField.cell setPlaceholderString:author];
-        self.authorTextField.delegate = self;
-    }
-    
-}
-- (IBAction)cancelButton_Click:(id)sender {
-    [self dismissViewController:self];
-}
-- (IBAction)okButton_Click:(id)sender {
-    if(self.callBack){
-        self.callBack();
-    }
-    [self cancelButton_Click:sender];
-}
-
-
-- (IBAction)selectAuthorButton_Click:(id)sender {
-    
-    //从沙盒中取出作者,如果没有
-    NSString *author = [[NSUserDefaults standardUserDefaults] objectForKey:@"CKUserName"];
-    author = [author length] ? author : NSFullUserName();
-
-    [self.authorTextField.cell setPlaceholderString:author];
-    self.dynamicStampNeedsAuthor = !self.dynamicStampNeedsAuthor;
-    
-    if (self.authorButton.state == NSControlStateValueOn) {
-        self.authorTextField.editable = YES;
-        [self.authorTextField becomeFirstResponder];
-        self.authorTextField.stringValue = author;
-    } else {
-        self.authorTextField.editable = NO;
-        self.authorTextField.stringValue = @"";
-        [self.authorTextField resignFirstResponder];
-    }
-    [[NSUserDefaults standardUserDefaults] setBool:!self.dynamicStampNeedsAuthor forKey:CPDFDynamicStampNeedAuthorKey1];
-    [[NSUserDefaults standardUserDefaults] synchronize];
-}
-
-#pragma mark - NSComboBoxDelegate
-
-- (void)comboBoxSelectionDidChange:(NSNotification *)notification
-{
-    NSComboBox *box = notification.object;
-    NSInteger selectIndex = [box indexOfSelectedItem];
-    self.dateFormatterString = self.dateStyleArray[selectIndex];
-    [[NSUserDefaults standardUserDefaults] setObject:self.dateFormatterString forKey:CPDFDynamicStampDateStyleKey1];
-}
-
-#pragma mark - NSTextfieldDelegate
-
-- (void) controlTextDidEndEditing:(NSNotification *)obj
-{
-    NSString *userName = self.authorTextField.stringValue.length > 0 ? self.authorTextField.stringValue : @"";
-    
-    [[NSUserDefaults standardUserDefaults] setObject:userName forKey:@"SKUserName"];
-    [[NSUserDefaults standardUserDefaults] synchronize];
-
-}
-
-@end

+ 136 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMDynamicStampViewController.swift

@@ -0,0 +1,136 @@
+//
+//  KMDynamicStampViewController.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/10/13.
+//
+
+import Cocoa
+typealias UpdateStampCallBack = () -> Void
+
+@objcMembers class KMDynamicStampViewController: NSViewController, NSComboBoxDelegate, NSTextFieldDelegate {
+    @IBOutlet weak var titleTextField: NSTextField!
+    @IBOutlet weak var preViewImageView: NSImageView!
+    @IBOutlet weak var authorButton: NSButton!
+    @IBOutlet weak var authorTextField: NSTextField!
+    @IBOutlet weak var timeTextField: NSTextField!
+    @IBOutlet weak var showTimeBox: NSComboBox!
+    @IBOutlet weak var okButton: NSButton!
+    @IBOutlet weak var cancel: NSButton!
+    
+    var callBack: UpdateStampCallBack?
+    
+    var dateStyleArray: [String] = []
+    var dateFormatterString: String = ""
+    var dynamicStampNeedsAuthor: Bool = false
+    
+    override func viewDidAppear() {
+        super.viewDidAppear()
+        self.view.window?.title = ""
+        self.view.window?.styleMask.insert(.fullSizeContentView)
+        self.view.window?.titlebarAppearsTransparent = true
+        self.view.window?.standardWindowButton(.closeButton)?.isHidden = true
+        self.view.window?.standardWindowButton(.miniaturizeButton)?.isHidden = true
+        self.view.window?.standardWindowButton(.zoomButton)?.isHidden = true
+    }
+    
+    override func viewDidLoad() {
+        super.viewDidLoad()
+        titleTextField.stringValue = NSLocalizedString("DynamicStamp", comment: "")
+        authorButton.title = NSLocalizedString("author", comment: "")
+        timeTextField.stringValue = NSLocalizedString("Time", comment: "")
+        
+        dateStyleArray = KMStampManager.defaultManager.dateStyleArray() 
+        showTimeBox.removeAllItems()
+        showTimeBox.addItems(withObjectValues: dateStyleArray)
+        showTimeBox.delegate = self
+        
+        //从沙盒中取出日期格式
+        let dateStyleIndicate = UserDefaults.standard.string(forKey: CPDFDynamicStampDateStyleKey1)
+        if let dateStyleIndicate = dateStyleIndicate, dateStyleIndicate.isEmpty {
+            showTimeBox.selectItem(at: dateStyleArray.count - 1)
+            dateFormatterString = dateStyleArray.last ?? ""
+        } else {
+            if let index = dateStyleArray.firstIndex(of: dateStyleIndicate!) {
+                showTimeBox.selectItem(at: index)
+                dateFormatterString = dateStyleIndicate!
+            } else {
+                showTimeBox.selectItem(at: dateStyleArray.count - 1)
+                dateFormatterString = dateStyleArray.last ?? ""
+            }
+        }
+        
+        //从沙盒中取出是否需要作者
+        let isNeedAuthor = UserDefaults.standard.bool(forKey: CPDFDynamicStampNeedAuthorKey1)
+        
+        dynamicStampNeedsAuthor = !isNeedAuthor
+        authorButton.state = dynamicStampNeedsAuthor ? .on : .off
+        
+        var author = UserDefaults.standard.string(forKey: "CKUserName") ?? ""
+        author = author.isEmpty ? NSFullUserName() : author
+        
+        if dynamicStampNeedsAuthor {
+            authorTextField.isEditable = true
+            authorTextField.isSelectable = true
+            authorTextField.stringValue = author
+            authorTextField.placeholderString = ""
+            authorTextField.delegate = self
+        } else {
+            authorTextField.isEditable = false
+            authorTextField.isSelectable = false
+            authorTextField.stringValue = ""
+            authorTextField.placeholderString = author
+            authorTextField.delegate = self
+        }
+    }
+    
+    @IBAction func cancelButtonClick(_ sender: Any) {
+        dismiss(self)
+    }
+    
+    @IBAction func okButtonClick(_ sender: Any) {
+        if let callBack = callBack {
+            callBack()
+        }
+        cancelButtonClick(self)
+    }
+    
+    @IBAction func selectAuthorButtonClick(_ sender: Any) {
+        //从沙盒中取出作者,如果没有
+        var author = UserDefaults.standard.string(forKey: "CKUserName") ?? ""
+        author = author.isEmpty ? NSFullUserName() : author
+
+        authorTextField.placeholderString = author
+        dynamicStampNeedsAuthor = !dynamicStampNeedsAuthor
+
+        if authorButton.state == .on {
+            authorTextField.isEditable = true
+            authorTextField.becomeFirstResponder()
+            authorTextField.stringValue = author
+        } else {
+            authorTextField.isEditable = false
+            authorTextField.stringValue = ""
+            authorTextField.resignFirstResponder()
+        }
+        UserDefaults.standard.set(!dynamicStampNeedsAuthor, forKey: CPDFDynamicStampNeedAuthorKey1)
+        UserDefaults.standard.synchronize()
+    }
+    
+    // MARK: - NSComboBoxDelegate
+    
+    func comboBoxSelectionDidChange(_ notification: Notification) {
+        if let box = notification.object as? NSComboBox {
+            let selectIndex = box.indexOfSelectedItem
+            dateFormatterString = dateStyleArray[selectIndex]
+            UserDefaults.standard.set(dateFormatterString, forKey: CPDFDynamicStampDateStyleKey1)
+        }
+    }
+    
+    // MARK: - NSTextfieldDelegate
+    
+    func controlTextDidEndEditing(_ obj: Notification) {
+        let userName = authorTextField.stringValue.isEmpty ? "" : authorTextField.stringValue
+        UserDefaults.standard.set(userName, forKey: "SKUserName")
+        UserDefaults.standard.synchronize()
+    }
+}

+ 7 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMDynamicStampViewController.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22154" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22154"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
@@ -12,7 +12,7 @@
                 <outlet property="authorTextField" destination="h04-zJ-ESh" id="qn1-fK-Jga"/>
                 <outlet property="cancel" destination="W8O-AB-LV3" id="ay8-hI-e2d"/>
                 <outlet property="okButton" destination="409-nL-biZ" id="FHC-My-gWh"/>
-                <outlet property="showTimeBox" destination="NB2-m7-l19" id="paV-Jm-Gia"/>
+                <outlet property="showTimeBox" destination="NB2-m7-l19" id="DdH-wn-KVf"/>
                 <outlet property="timeTextField" destination="Gp9-c5-GxZ" id="j2p-YC-Lpd"/>
                 <outlet property="titleTextField" destination="hDL-yw-0LU" id="X5Z-xk-nCr"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
@@ -24,7 +24,7 @@
             <rect key="frame" x="0.0" y="0.0" width="391" height="141"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hDL-yw-0LU">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hDL-yw-0LU">
                     <rect key="frame" x="13" y="110" width="37" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="Oe9-9H-SuI">
                         <font key="font" usesAppearanceFont="YES"/>
@@ -42,7 +42,7 @@
                         <action selector="selectAuthorButton_Click:" target="-2" id="Bvq-Dm-qUu"/>
                     </connections>
                 </button>
-                <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h04-zJ-ESh">
+                <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="h04-zJ-ESh">
                     <rect key="frame" x="76" y="66" width="96" height="21"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="96" id="hQm-5b-VGC"/>
@@ -53,7 +53,7 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gp9-c5-GxZ">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Gp9-c5-GxZ">
                     <rect key="frame" x="214" y="68" width="34" height="16"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Time" id="kru-3C-8Dj">
                         <font key="font" metaFont="system"/>
@@ -90,7 +90,7 @@ Gw
                         <action selector="cancelButton_Click:" target="-2" id="RD5-nw-nr5"/>
                     </connections>
                 </button>
-                <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NB2-m7-l19" customClass="KMComboBox" customModule="PDF_Office" customModuleProvider="target">
+                <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="NB2-m7-l19" customClass="KMComboBox" customModule="PDF_Master" customModuleProvider="target">
                     <rect key="frame" x="255" y="64" width="124" height="23"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="120" id="usv-QX-7LK"/>

+ 0 - 45
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMStampManager.h

@@ -1,45 +0,0 @@
-//
-//  KMStampManager.h
-//  SignFlow Premium
-//
-//  Created by wangshuai on 14/12/1.
-//  Copyright (c) 2014年 zhangjie. All rights reserved.
-//
-
-#import <Foundation/Foundation.h>
-
-#if VERSION_DMG
-#import <PDF_Master-Swift.h>
-#else
-#import <PDF_Master-Swift.h>
-#endif
-
-#define kmDynamicStamp   @"COfficeDynamicStamp"
-#define kmDigitalStamp   @"COfficeDigitalStamp"
-#define kmStandardStamp  @"COfficeStandardStamp"
-#define CPDFDynamicStampDateStyleKey1 @"C_pdfview_dynamic_stamp_date_style"
-#define CPDFDynamicStampNeedAuthorKey1  @"km_pdfview_dynamic_stamp_need_author"
-
-@interface KMStampManager : NSObject
-
-@property (nonatomic,strong) NSMutableArray <CStampObject*>*stamps;
-
-+ (KMStampManager *)defaultManager;
-
-- (BOOL)addStampWithString:(NSString *)string categoryString:(CPDFStampType )categoryString nameString:(NSString *)nameString dateString:(NSString *)dateString needExchangeFontSize:(BOOL)needExchange color:(CPDFStampStyle)color shape:(CPDFStampShape)shape date:(NSString *)date time:(NSString *)time;
-- (BOOL)addStampWithImagePath:(NSString *)path categoryString:(CPDFStampType)categoryString nameString:(NSString *)nameString;
-- (BOOL)addStampWithImagePath:(NSString *)path categoryString:(CPDFStampType)categoryString nameString:(NSString *)nameString isRemoveBGColor:(BOOL)isRemoveBGColor;
-
-- (BOOL)removeStampAtIndex:(NSInteger)index;
-
-- (BOOL)removeStamp:(CStampObject *)stamp;
-
-- (void)addStamp:(CStampObject *)stamp;
-
-- (NSMutableArray*)dynamicStamps;
-
-- (NSString *)setDynamicStampDateStringWithDateStyle:(NSString *)dateStyleString;
-
-- (NSArray *)dateStyleArray;
-
-@end

+ 0 - 644
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMStampManager.m

@@ -1,644 +0,0 @@
-//
-//  KMStampManager.m
-//  SignFlow Premium
-//
-//  Created by wangshuai on 14/12/1.
-//  Copyright (c) 2014年 zhangjie. All rights reserved.
-//
-
-#import "KMStampManager.h"
-
-#define kmApplicationSupportDirectory  [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:[NSBundle mainBundle].bundleIdentifier]
-#define kStampFolderPath [kmApplicationSupportDirectory stringByAppendingPathComponent:@"COfficeStamp"]
-#define kStampPlistPath  [[kmApplicationSupportDirectory stringByAppendingPathComponent:@"COfficeStamp"] stringByAppendingPathComponent:@"COfficeStamp.plist"]
-
-#define kStampOfStringKey    @"StampStringKey"
-#define kStampOfSubStringKey @"StampSubStringKey"
-#define kStampOfColorKey     @"StampColorKey"
-#define kStampOfImagePathKey @"StampImagePathKey"
-#define kStampOfDateKey      @"kStampOfDateKey"
-#define kStampOfCategoryKey  @"kStampOfCategoryKey"
-#define kStampOfNameKey  @"kStampOfNameKey"
-#define kStampShapeKey  @"kStampShapeKey"
-#define kStampDateKey  @"kStampDateKey"
-#define kStampTimeKey  @"kStampTimeKey"
-#define kStampNeedExchangKey  @"kStampNeedExchangKey"
-
-@implementation KMStampManager
-
-- (NSString *)tagString {
-    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
-    dateFormatter.dateFormat    = @"yyMMddHHmmss";
-    return [NSString stringWithFormat:@"%@%04d", [dateFormatter stringFromDate:[NSDate date]], rand()%10000];
-}
-
-+ (KMStampManager *)defaultManager
-{
-    static KMStampManager *singleton = nil;
-    static dispatch_once_t pred;
-    dispatch_once(&pred, ^{
-        singleton = [[KMStampManager alloc] init];
-    });
-    return singleton;
-}
-
-- (id)init
-{
-    if (self = [super init]) {
-        _stamps = [[NSMutableArray alloc] init];
-        [_stamps addObjectsFromArray:[self defaultStandardStamps]];
-        [_stamps addObjectsFromArray:[self dynamicStamps]];
-        if ([[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-            NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-            NSMutableArray *deleteKeys = [NSMutableArray array];
-            for (NSString *key in [dictionary allKeys]) {
-                NSDictionary *dic = [dictionary objectForKey:key];
-                
-                BOOL isAdd = YES;
-                NSString *text = @"";
-                NSString *dateString = @"";
-                NSInteger color = 0;
-                NSString *date = @"";
-                NSInteger categorytype = 0;
-                NSString *nameString = @"";
-                NSString *imagePath = @"";
-                NSInteger stampShape = 0;
-                BOOL needChange = NO;
-                if ([dic objectForKey:kStampOfStringKey]) {
-                    text = [dic objectForKey:kStampOfStringKey];
-                }
-                if ([dic objectForKey:kStampOfSubStringKey]) {
-                    dateString = [dic objectForKey:kStampOfSubStringKey];
-                }
-                if ([dic objectForKey:kStampOfColorKey]) {
-                    color = [[dic objectForKey:kStampOfColorKey] integerValue];
-                }
-                if ([dic objectForKey:kStampOfDateKey]) {
-                    date = [dic objectForKey:kStampOfDateKey];
-                }
-                
-                if ([dic objectForKey:kStampOfCategoryKey]) {
-                    categorytype = [[dic objectForKey:kStampOfCategoryKey] integerValue];
-                }
-                
-                if ([dic objectForKey:kStampOfNameKey]) {
-                    nameString = [dic objectForKey:kStampOfNameKey];
-                }
-                
-                if ([dic objectForKey:kStampShapeKey]) {
-                    stampShape = [[dic objectForKey:kStampShapeKey] integerValue];
-                }
-                
-                if ([dic objectForKey:kStampNeedExchangKey]) {
-                    needChange = [[dic objectForKey:kStampNeedExchangKey] boolValue];
-                }
-                
-                if ([dic objectForKey:kStampOfImagePathKey]) {
-                    NSString *path = [kStampFolderPath stringByAppendingPathComponent:[dic objectForKey:kStampOfImagePathKey]];
-                    if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
-                        imagePath = path;
-                    } else {
-                        isAdd = NO;
-                        [deleteKeys addObject:key];
-                    }
-                }
-                CStampObject *stamp = nil;
-                if(imagePath.length > 0 && categorytype == 2) {
-                    stamp = [[CStampObject alloc] initWithImageStampFilePath:imagePath];
-                } else {
-                    if (categorytype == 4) {
-                        isAdd = NO;
-                    } else if (categorytype == 1) {
-                        NSString *dateS = @"";
-                        NSString *time = @"";
-                        if ([dic objectForKey:kStampDateKey]) {
-                            dateS = [dic objectForKey:kStampDateKey];
-                        }
-                        if ([dic objectForKey:kStampTimeKey]) {
-                            time = [dic objectForKey:kStampTimeKey];
-                        }
-                        stamp = [[CStampObject alloc] initWithText:text detailText:dateString style:color shape:stampShape];
-                        stamp.dateString = dateS;
-                        stamp.timeString = time;
-                    }
-                }
-                stamp.stampKey = key;
-                if (isAdd) {
-                    [self.stamps addObject:stamp];
-                }
-            }
-            
-            if (deleteKeys.count > 0) {
-                NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-                for (NSString *key in deleteKeys) {
-                    [newDictionary removeObjectForKey:key];
-                }
-                [newDictionary writeToFile:kStampPlistPath atomically:YES];
-            }
-        }
-    }
-    return self;
-}
-
-#pragma mark - Default Data
-
-- (NSMutableArray *)defaultStandardStamps {
-    NSMutableArray *dynamic = [[NSMutableArray alloc] init];
-    NSArray *standarArray = @[@(CStandardStampTypeApproved),
-                              @(CStandardStampTypeNotapproved),
-                              @(CStandardStampTypeDraft),
-                              @(CStandardStampTypeFinal),
-                              @(CStandardStampTypeCompleted),
-                              @(CStandardStampTypeConfidential),
-                              @(CStandardStampTypeForpublicrelease),
-                              @(CStandardStampTypeNotforpublicrelease),
-                              @(CStandardStampTypeForcomment),
-                              @(CStandardStampTypeVoid),
-                              @(CStandardStampTypePreliminaryresults),
-                              @(CStandardStampTypeInformationonly),
-                              @(CStandardStampTypeWitness),
-                              @(CStandardStampTypeInitialhere),
-                              @(CStandardStampTypeSignhere),
-                              @(CStandardStampTypeRevised),
-                              @(CStandardStampTypeAccepted),
-                              @(CStandardStampTypeRejected),
-                              @(CStandardStampTypeChick),
-                              @(CStandardStampTypeCross),
-                              @(CStandardStampTypeCircle),
-                              @(CStandardStampTypeEmergency),
-                              @(CStandardStampTypeExpired),
-                              @(CStandardStampTypeReceived),
-                              @(CStandardStampTypeReviewed),
-                              @(CStandardStampTypeVerified),
-                              @(CStandardStampTypeAccepteder),
-                              @(CStandardStampTypeRejecteder)];
-    for(int i = 0;i<standarArray.count;i++) {
-        NSNumber *index = standarArray[i];
-        CStampObject *object = [[CStampObject alloc] initWithStandardStampType:[index intValue]];
-
-        [dynamic addObject:object];
-    }
-    return dynamic;
-}
-
-- (NSMutableArray*)dynamicStamps {
-    NSMutableArray *dynamicStampArray = [[NSMutableArray alloc] init];
-    //从沙盒中取出日期格式
-    NSString *dateStyleIndicate = [[NSUserDefaults standardUserDefaults] objectForKey:CPDFDynamicStampDateStyleKey1];
-    NSString *dateFormatterString = @"";
-    if (dateStyleIndicate.length < 1) {
-        dateFormatterString = self.dateStyleArray.lastObject;
-    } else {
-        NSInteger index = [self.dateStyleArray indexOfObject:dateStyleIndicate];
-        if (index > self.dateStyleArray.count) {
-            dateFormatterString = self.dateStyleArray.lastObject;
-        }else{
-            dateFormatterString = dateStyleIndicate;
-        }
-    }
-    NSString *dateString = [self setDynamicStampDateStringWithDateStyle:dateFormatterString];
-    NSArray *dynamicArray = @[@"REVISED",@"REVIEWED",@"RECEIVED",@"APPROVED",@"Michael"];
-    NSString *author = [[NSUserDefaults standardUserDefaults] stringForKey:@"CKUserName"];
-    //从沙盒中取出是否需要作者
-    BOOL isNeedAuthor = [[NSUserDefaults standardUserDefaults] boolForKey:CPDFDynamicStampNeedAuthorKey1];
-    if(!isNeedAuthor) {
-        author = [author length] ? author : NSFullUserName();
-        dateString = [NSString stringWithFormat:@"By %@ at %@",author,dateString];
-    } else {
-        author = @"";
-    }
-    
-    [dynamicArray enumerateObjectsUsingBlock:^(NSString*  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
-        CPDFStampStyle style = CPDFStampStyleRed;
-        if(idx>0 && idx<4) {
-            style = CPDFStampStyleGreen;
-        }
-        CStampObject *stamp = [[CStampObject alloc] initWithDynamicText:obj dynamicDetailText:dateString dynamicStyle:style needExchangeFontSize:NO dynamicShape:CPDFStampShapeRectangle];
-        if(idx == 4) {
-            stamp = [[CStampObject alloc] initWithDynamicText:obj dynamicDetailText:dateString dynamicStyle:style needExchangeFontSize:YES dynamicShape:CPDFStampShapeRectangle];
-        }
-        [dynamicStampArray addObject:stamp];
-    }];
-    
-    return dynamicStampArray;
-}
-
-
-#pragma mark -- Public
-
-- (BOOL)addStampWithString:(NSString *)string categoryString:(CPDFStampType )categoryString nameString:(NSString *)nameString dateString:(NSString *)dateString needExchangeFontSize:(BOOL)needExchange color:(CPDFStampStyle)color shape:(CPDFStampShape)shape date:(NSString *)date time:(NSString *)time
-{
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampFolderPath]) {
-        if (![[NSFileManager defaultManager] createDirectoryAtPath:kStampFolderPath withIntermediateDirectories:YES attributes:nil error:nil]) {
-            return NO;
-        }
-    }
-    
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-        if (![[NSFileManager defaultManager] createFileAtPath:kStampPlistPath contents:nil attributes:nil]) {
-            return NO;
-        }
-    }
-    
-    NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-    NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-    
-    NSString *tag = [self tagString];
-    NSString *text = @"";
-    NSString *detailText = @"";
-    
-    NSMutableDictionary *stampDictionary = [[NSMutableDictionary alloc] init];
-    if (string) {
-        [stampDictionary setObject:string forKey:kStampOfStringKey];
-        text = string;
-    }
-    if (dateString) {
-        [stampDictionary setObject:dateString forKey:kStampOfSubStringKey];
-        detailText = dateString;
-    }
-    if (date) {
-        [stampDictionary setObject:date forKey:kStampDateKey];
-    }
-    if (time) {
-        [stampDictionary setObject:time forKey:kStampTimeKey];
-    }
-    [stampDictionary setObject:@(categoryString) forKey:kStampOfCategoryKey];
-    
-    if(nameString) {
-        [stampDictionary setObject:nameString forKey:kStampOfNameKey];
-        detailText = [NSString stringWithFormat:@"%@ %@",detailText,nameString];
-    }
-    [stampDictionary setObject:[NSNumber numberWithInteger:color] forKey:kStampOfColorKey];
-    [stampDictionary setObject:[NSDate date] forKey:kStampOfDateKey];
-    [stampDictionary setObject:needExchange? @"1":@"0" forKey:kStampNeedExchangKey];
-    [newDictionary setObject:stampDictionary forKey:tag];
-    
-    CStampObject *stamp = nil;
-    if (categoryString == 4) {
-      
-    } else if (categoryString == 1) {
-        stamp = [[CStampObject alloc] initWithText:text detailText:dateString style:color shape:shape];
-        stamp.dateString = date;
-        stamp.timeString = time;
-    }
-    if ([newDictionary writeToFile:kStampPlistPath atomically:YES] && stamp) {
-        stamp.stampKey = tag;
-        [self.stamps addObject:stamp];
-        return YES;
-    }
-    return NO;
-}
-
-- (BOOL)addStampWithImagePath:(NSString *)path categoryString:(CPDFStampType)categoryString nameString:(NSString *)nameString
-{
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampFolderPath]) {
-        if (![[NSFileManager defaultManager] createDirectoryAtPath:kStampFolderPath withIntermediateDirectories:YES attributes:nil error:nil]) {
-            return NO;
-        }
-    }
-    
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-        if (![[NSFileManager defaultManager] createFileAtPath:kStampPlistPath contents:nil attributes:nil]) {
-            return NO;
-        }
-    }
-    
-    NSString *tag = [self tagString];
-    NSString *rPath = [kStampFolderPath stringByAppendingPathComponent:[tag stringByAppendingPathExtension:@"jpg"]];
-    
-    NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
-    [image lockFocus];
-    NSBitmapImageRep *bits = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0, 0, image.size.width, image.size.height)];
-    [image unlockFocus];
-    NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:0.5] forKey:NSImageCompressionFactor];
-    NSData *imageData = [bits representationUsingType:NSJPEGFileType properties:imageProps];
-    if (![imageData writeToFile:rPath atomically:YES]) {
-        return NO;
-    }
-    
-    NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-    NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-    
-    CStampObject *stamp = [[CStampObject alloc] initWithImageStampFilePath:rPath];
-    stamp.nameString = nameString;
-    
-    NSMutableDictionary *stampDictionary = [[NSMutableDictionary alloc] init];
-    [stampDictionary setObject:[rPath lastPathComponent] forKey:kStampOfImagePathKey];
-    [stampDictionary setObject:[NSDate date] forKey:kStampOfDateKey];
- 
-    [stampDictionary setObject:@(categoryString) forKey:kStampOfCategoryKey];
-    
-    if(nameString) {
-        [stampDictionary setObject:nameString forKey:kStampOfNameKey];
-    }
-    [newDictionary setObject:stampDictionary forKey:tag];
-    
-    if ([newDictionary writeToFile:kStampPlistPath atomically:YES]) {
-        stamp.stampKey = tag;
-        [self.stamps addObject:stamp];
-        return YES;
-    }
-   
-    return NO;
-}
-
-- (BOOL)addStampWithImagePath:(NSString *)path  categoryString:(CPDFStampType)categoryString nameString:(NSString *)nameString isRemoveBGColor:(BOOL)isRemoveBGColor
-{
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampFolderPath]) {
-        if (![[NSFileManager defaultManager] createDirectoryAtPath:kStampFolderPath withIntermediateDirectories:YES attributes:nil error:nil]) {
-            return NO;
-        }
-    }
-    
-    if (![[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-        if (![[NSFileManager defaultManager] createFileAtPath:kStampPlistPath contents:nil attributes:nil]) {
-            return NO;
-        }
-    }
-    
-    NSString *tag = [self tagString];
-    NSString *rPath = [kStampFolderPath stringByAppendingPathComponent:[tag stringByAppendingPathExtension:@"jpg"]];
-    
-    if (isRemoveBGColor) {
-        NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
-        NSData *imageData = [image TIFFRepresentation];
-        CGImageRef imageRef;
-        if (imageData) {
-            CGImageSourceRef imageSource = CGImageSourceCreateWithData((CFDataRef)imageData, NULL);
-            imageRef = CGImageSourceCreateImageAtIndex(imageSource, 0, NULL);
-        }
-        
-        const int imageWidth = image.size.width;
-        const int imageHeight = image.size.height;
-        size_t bytesPerRow = imageWidth * 4;
-        uint32_t* rgbImageBuf = (uint32_t*)malloc(bytesPerRow * imageHeight);
-        
-        CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-        CGContextRef context = CGBitmapContextCreate(rgbImageBuf,
-                                                     imageWidth,
-                                                     imageHeight,
-                                                     8,
-                                                     bytesPerRow,
-                                                     colorSpace,
-                                                     kCGBitmapByteOrder32Little | kCGImageAlphaNoneSkipLast);
-        CGContextDrawImage(context, CGRectMake(0, 0, imageWidth, imageHeight), imageRef);
-        
-        int pixelNum = imageWidth * imageHeight;
-        uint32_t* pCurPtr = rgbImageBuf;
-        for (int i = 0; i < pixelNum; i++, pCurPtr++) {
-            uint8_t* ptr = (uint8_t*)pCurPtr;
-            if (ptr[1] > 240 && ptr[2] > 240 && ptr[3] > 240) {
-                ptr[0] = 0;
-            }
-        }
-        
-        CGDataProviderRef dataProvider = CGDataProviderCreateWithData(NULL, rgbImageBuf, bytesPerRow * imageHeight, nil);
-        imageRef = CGImageCreate(imageWidth,
-                                 imageHeight,
-                                 8,
-                                 32,
-                                 bytesPerRow,
-                                 colorSpace,
-                                 kCGImageAlphaLast |kCGBitmapByteOrder32Little,
-                                 dataProvider,
-                                 NULL,
-                                 true,
-                                 kCGRenderingIntentDefault);
-        CGDataProviderRelease(dataProvider);
-        
-        NSImage *newImage = nil;
-        if (imageRef) {
-            NSRect imageRect = NSMakeRect(0.0, 0.0, 0.0, 0.0);
-            CGContextRef imageContext = nil;
-            
-            // Get the image dimensions.
-            imageRect.size.height = CGImageGetHeight(imageRef);
-            imageRect.size.width = CGImageGetWidth(imageRef);
-            
-            // Create a new image to receive the Quartz image data.
-            newImage = [[NSImage alloc] initWithSize:imageRect.size];
-            [newImage lockFocus];
-            
-            // Get the Quartz context and draw.
-            imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
-            CGContextDrawImage(imageContext, *(CGRect*)&imageRect, imageRef);
-            [newImage unlockFocus];
-            CGImageRelease(imageRef);
-        }
-        image = newImage;
-        
-        [image lockFocus];
-        NSBitmapImageRep *bits = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0, 0, image.size.width, image.size.height)];
-        [image unlockFocus];
-        NSDictionary *imageProps = [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.0] forKey:NSImageCompressionFactor];
-        imageData = [bits representationUsingType:NSPNGFileType properties:imageProps];
-        if (![imageData writeToFile:rPath atomically:YES]) {
-            return NO;
-        }
-    } else {
-        if ([path.pathExtension.lowercaseString isEqualToString:@"pdf"]) {
-            NSImage *image = [[NSImage alloc] initWithContentsOfFile:path];
-            NSData *imageData = [image TIFFRepresentation];
-            if (![imageData writeToFile:rPath atomically:YES]) {
-                return NO;
-            }
-        } else {
-            if (![[NSFileManager defaultManager] copyItemAtPath:path toPath:rPath error:nil]) {
-                return NO;
-            }
-            
-        }
-    }
-    
-    NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-    NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-    
-//    KMPDFStamp *stamp = [[[KMPDFStamp alloc] init] autorelease];
-//    stamp.isImageStamp = YES;
-//    stamp.date = [NSDate date];
-//    stamp.imagePath = rPath;
-//    stamp.tag = tag;
-//    stamp.categoryString = categoryString;
-//    stamp.nameString = nameString;
-    
-    NSMutableDictionary *stampDictionary = [[NSMutableDictionary alloc] init];
-    [stampDictionary setObject:[rPath lastPathComponent] forKey:kStampOfImagePathKey];
-    [stampDictionary setObject:[NSDate date] forKey:kStampOfDateKey];
-    [stampDictionary setObject:@(categoryString) forKey:kStampOfCategoryKey];
-    if(nameString) {
-        [stampDictionary setObject:nameString forKey:kStampOfNameKey];
-    }
-    
-    [newDictionary setObject:stampDictionary forKey:tag];
-    
-    if ([newDictionary writeToFile:kStampPlistPath atomically:YES]) {
-//        [self.stamps addObject:stamp];
-//        if(![self.stampCategorys containsObject:categoryString]) {
-//            [self.stampCategorys addObject:categoryString];
-//        }
-    }
-    return NO;
-}
-
-- (BOOL)removeStampAtIndex:(NSInteger)index
-{
-    if (index < self.stamps.count) {
-        CStampObject *stamp = [self.stamps objectAtIndex:index];
-        NSString *key = stamp.stampKey;
-        
-        if (![[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-            return NO;
-        }
-        
-        NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-        NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-
-        [newDictionary removeObjectForKey:@"key"];
-        
-        if ([newDictionary writeToFile:kStampPlistPath atomically:YES]) {
-            if (stamp.imagePath && stamp.imagePath.length > 0) {
-                [[NSFileManager defaultManager] removeItemAtPath:stamp.imagePath error:nil];
-            }
-            [self.stamps removeObject:stamp];
-            return YES;
-        }
-    }
-    return NO;
-}
-
-- (BOOL)removeStamp:(CStampObject *)stamp {
-    if(!stamp) {
-        return NO;
-    }
-    if([self.stamps containsObject:stamp]) {
-        NSString *key = stamp.stampKey;
-        
-        if (![[NSFileManager defaultManager] fileExistsAtPath:kStampPlistPath]) {
-            return NO;
-        }
-        
-        NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfFile:kStampPlistPath];
-        NSMutableDictionary *newDictionary = [NSMutableDictionary dictionaryWithDictionary:dictionary];
-
-        [newDictionary removeObjectForKey:key];
-        
-        if ([newDictionary writeToFile:kStampPlistPath atomically:YES]) {
-            if (stamp.imagePath && stamp.imagePath.length > 0) {
-                [[NSFileManager defaultManager] removeItemAtPath:stamp.imagePath error:nil];
-            }
-            [self.stamps removeObject:stamp];
-            return YES;
-        }
-    }
-    return NO;
-}
-
-- (void)addStamp:(CStampObject *)stamp {
-    if(!stamp)
-        return;
-    if (stamp.stampCategoryType == CPDFStampTypeText) {
-        [self addStampWithString:stamp.text categoryString:CPDFStampTypeText nameString:@"" dateString:stamp.detailText needExchangeFontSize:NO color:stamp.style shape:stamp.shape date:stamp.dateString time:stamp.timeString];
-    } else if(stamp.stampCategoryType == CPDFStampTypeImage) {
-        [self addStampWithImagePath:stamp.imagePath categoryString:CPDFStampTypeImage nameString:@""];
-    }
-}
-
-//根据不同的日期格式字符串获取最终的dateString
-- (NSString *)setDynamicStampDateStringWithDateStyle:(NSString *)dateStyleString
-{
-    NSDate *now = [NSDate date];
-    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
-    
-    if ([dateStyleString isEqualToString:@"m/d"]) {
-        formatter.dateFormat = @"M/dd HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"m/d/yy"]){
-        formatter.dateFormat = @"M/dd/yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"m/d/yyyy"]){
-        formatter.dateFormat = @"MM/dd/yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"mm/dd/yy"]){
-        formatter.dateFormat = @"MM/dd/yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"mm/dd/yyyy"]){
-        formatter.dateFormat = @"MM/dd/yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"d/m/yy"]){
-        formatter.dateFormat = @"d/m/yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"d/m/yyyy"]){
-        formatter.dateFormat = @"d/m/yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"dd/mm/yy"]){
-        formatter.dateFormat = @"dd/MM/yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"dd/mm/yyyy"]){
-        formatter.dateFormat = @"dd/mm/yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"mm/yy"]){
-        formatter.dateFormat = @"MM/yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"mm/yyyy"]){
-        formatter.dateFormat = @"MM/yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"m.d.yy"]){
-        formatter.dateFormat = @"M.d.yy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"m.d.yyyy"]){
-        formatter.dateFormat = @"M.d.yyyy HH:mm:ss";
-    }else if ([dateStyleString isEqualToString:@"mm.dd.yy"]){
-        formatter.dateFormat = @"MM.dd.yy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"mm.dd.yyyy"]){
-        formatter.dateFormat = @"MM.dd.yyyy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"mm.yy"]){
-        formatter.dateFormat = @"MM.yyyy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"mm.yyyy"]){
-        formatter.dateFormat = @"MM.yyyy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"d.m.yy"]){
-        formatter.dateFormat = @"d.M.yy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"d.m.yyyy"]){
-        formatter.dateFormat = @"d.M.yyyy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"dd.mm.yy"]){
-        formatter.dateFormat = @"dd.MM.yy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"dd.mm.yyyy"]){
-        formatter.dateFormat = @"d.MM.yyyy HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"yy-mm-dd"]){
-        formatter.dateFormat = @"yy-MM-dd HH:mm:ss";
-    }
-    else if ([dateStyleString isEqualToString:@"yyyy-mm-dd"]){
-        formatter.dateFormat = @"yyy-MM-dd HH:mm:ss";
-    } else {
-        formatter.dateStyle =  kCFDateFormatterMediumStyle;
-        formatter.timeStyle = kCFDateFormatterShortStyle;
-    }
-    
-    NSString *str = [formatter stringFromDate:now];
-
-    return str;
-}
-
-- (NSArray *)dateStyleArray {
-    return @[@"m/d",
-            @"m/d/yy",
-            @"m/d/yyyy",
-            @"mm/dd/yy",
-            @"mm/dd/yyyy",
-            @"d/m/yy",
-            @"d/m/yyyy",
-            @"dd/mm/yy",
-            @"dd/mm/yyyy",
-            @"mm/yy",
-            @"mm/yyyy",
-            @"m.d.yy",
-            @"m.d.yyyy",
-            @"mm.dd.yy",
-            @"mm.dd.yyyy",
-            @"mm.yy",
-            @"mm.yyyy",
-            @"d.m.yy",
-            @"d.m.yyyy",
-            @"dd.mm.yy",
-            @"dd.mm.yyyy",
-            @"yy-mm-dd",
-            @"yyyy-mm-dd",
-          NSLocalizedString(@"Default", nil)];
-}
-
-@end

+ 458 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMStampManager.swift

@@ -0,0 +1,458 @@
+//
+//  KMStampManager.swift
+//  PDF Master
+//
+//  Created by lizhe on 2023/10/12.
+//
+
+import Foundation
+
+let kmApplicationSupportDirectory = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).last!.appendingPathComponent(Bundle.main.bundleIdentifier ?? "")
+let kStampFolderPath = kmApplicationSupportDirectory.appendingPathComponent("COfficeStamp")
+let kStampPlistPath = kStampFolderPath.appendingPathComponent("COfficeStamp.plist")
+
+let kStampOfStringKey = "StampStringKey"
+let kStampOfSubStringKey = "StampSubStringKey"
+let kStampOfColorKey = "StampColorKey"
+let kStampOfImagePathKey = "StampImagePathKey"
+let kStampOfDateKey = "kStampOfDateKey"
+let kStampOfCategoryKey = "kStampOfCategoryKey"
+let kStampOfNameKey = "kStampOfNameKey"
+let kStampShapeKey = "kStampShapeKey"
+let kStampDateKey = "kStampDateKey"
+let kStampTimeKey = "kStampTimeKey"
+let kStampNeedExchangKey = "kStampNeedExchangKey"
+
+let CPDFDynamicStampDateStyleKey1 = "C_pdfview_dynamic_stamp_date_style"
+let CPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
+
+@objcMembers class KMStampManager: NSObject {
+    static let defaultManager = KMStampManager()
+    
+    var stamps: [CStampObject] = []
+    
+    func tagString() -> String {
+        let dateFormatter = DateFormatter()
+        dateFormatter.dateFormat = "yyMMddHHmmss"
+        return "\(dateFormatter.string(from: Date()))\(Int.random(in: 0..<10000))"
+    }
+    
+    override init() {
+        super.init()
+        stamps = []
+        stamps.append(contentsOf: defaultStandardStamps())
+        stamps.append(contentsOf: dynamicStamps())
+        
+        if FileManager.default.fileExists(atPath: kStampPlistPath.path),
+           let dictionary = NSDictionary(contentsOfFile: kStampPlistPath.path) as? [String: Any] {
+            
+            var deleteKeys: [String] = []
+            
+            for (key, value) in dictionary {
+                var isAdd = true
+                var text = ""
+                var dateString = ""
+                var color = 0
+                var date = ""
+                var categorytype = 0
+                var nameString = ""
+                var imagePath = ""
+                var stampShape = 0
+                var needChange = false
+                
+                if let dic = value as? [String: Any] {
+                    if let stampOfString = dic[kStampOfStringKey] as? String {
+                        text = stampOfString
+                    }
+                    if let stampOfSubString = dic[kStampOfSubStringKey] as? String {
+                        dateString = stampOfSubString
+                    }
+                    if let stampOfColor = dic[kStampOfColorKey] as? Int {
+                        color = stampOfColor
+                    }
+                    if let stampOfDate = dic[kStampOfDateKey] as? String {
+                        date = stampOfDate
+                    }
+                    if let stampOfCategory = dic[kStampOfCategoryKey] as? Int {
+                        categorytype = stampOfCategory
+                    }
+                    if let stampOfName = dic[kStampOfNameKey] as? String {
+                        nameString = stampOfName
+                    }
+                    if let stampShapeValue = dic[kStampShapeKey] as? Int {
+                        stampShape = stampShapeValue
+                    }
+                    if let stampNeedExchange = dic[kStampNeedExchangKey] as? Bool {
+                        needChange = stampNeedExchange
+                    }
+                    
+                    if let stampOfImagePathKey = dic[kStampOfImagePathKey] as? String {
+                        let path = kStampFolderPath.appendingPathComponent(stampOfImagePathKey).path
+                        if FileManager.default.fileExists(atPath: path) {
+                            imagePath = path
+                        } else {
+                            isAdd = false
+                            deleteKeys.append(key)
+                        }
+                    }
+                    
+                    var stamp: CStampObject?
+                    
+                    if !imagePath.isEmpty && categorytype == 2 {
+                        stamp = CStampObject(imageStampFilePath: imagePath)
+                    } else {
+                        if categorytype == 4 {
+                            isAdd = false
+                        } else if categorytype == 1 {
+                            var dateS = ""
+                            var time = ""
+                            if let stampDate = dic[kStampDateKey] as? String {
+                                dateS = stampDate
+                            }
+                            if let stampTime = dic[kStampTimeKey] as? String {
+                                time = stampTime
+                            }
+                            stamp = CStampObject(text: text, detailText: dateString, style: CPDFStampStyle(rawValue: color) ?? .white, shape: CPDFStampShape(rawValue: stampShape) ?? .none)
+                            stamp?.dateString = dateS
+                            stamp?.timeString = time
+                        }
+                    }
+                    
+                    stamp?.stampKey = key
+                    if isAdd, let stamp = stamp {
+                        stamps.append(stamp)
+                    }
+                }
+            }
+            
+            if !deleteKeys.isEmpty {
+                var newDictionary = dictionary
+                for key in deleteKeys {
+                    newDictionary.removeValue(forKey: key)
+                }
+                (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true)
+            }
+        }
+    }
+    
+    
+    func defaultStandardStamps() -> [CStampObject] {
+        var dynamic: [CStampObject] = []
+        let standarArray: [Int] = [
+            CStandardStampType.Approved.rawValue,
+            CStandardStampType.Notapproved.rawValue,
+            CStandardStampType.Draft.rawValue,
+            CStandardStampType.Final.rawValue,
+            CStandardStampType.Completed.rawValue,
+            CStandardStampType.Confidential.rawValue,
+            CStandardStampType.Forpublicrelease.rawValue,
+            CStandardStampType.Notforpublicrelease.rawValue,
+            CStandardStampType.Forcomment.rawValue,
+            CStandardStampType.Void.rawValue,
+            CStandardStampType.Preliminaryresults.rawValue,
+            CStandardStampType.Informationonly.rawValue,
+            CStandardStampType.Witness.rawValue,
+            CStandardStampType.Initialhere.rawValue,
+            CStandardStampType.Signhere.rawValue,
+            CStandardStampType.Revised.rawValue,
+            CStandardStampType.Accepted.rawValue,
+            CStandardStampType.Rejected.rawValue,
+            CStandardStampType.Chick.rawValue,
+            CStandardStampType.Cross.rawValue,
+            CStandardStampType.Circle.rawValue,
+            CStandardStampType.Emergency.rawValue,
+            CStandardStampType.Expired.rawValue,
+            CStandardStampType.Received.rawValue,
+            CStandardStampType.Reviewed.rawValue,
+            CStandardStampType.Verified.rawValue,
+            CStandardStampType.Accepteder.rawValue,
+            CStandardStampType.Rejecteder.rawValue
+        ]
+        
+        for index in standarArray {
+            let object = CStampObject(standardStampType: CStandardStampType(rawValue: index) ?? .Approved)
+            dynamic.append(object)
+        }
+        
+        return dynamic
+    }
+    
+    func dynamicStamps() -> [CStampObject] {
+        var dynamicStampArray: [CStampObject] = []
+        
+        // Retrieve date style from UserDefaults
+        let dateStyleIndicate = UserDefaults.standard.string(forKey: CPDFDynamicStampDateStyleKey1)
+        var dateFormatterString = ""
+        
+        if dateStyleIndicate?.isEmpty ?? true {
+            dateFormatterString = dateStyleArray().last ?? ""
+        } else {
+            if let index = dateStyleArray().firstIndex(of: dateStyleIndicate!) {
+                dateFormatterString = dateStyleIndicate!
+            }
+        }
+        
+        var dateString = setDynamicStampDateStringWithDateStyle(dateFormatterString)
+        
+        let dynamicArray = ["REVISED", "REVIEWED", "RECEIVED", "APPROVED", "Michael"]
+        var author = UserDefaults.standard.string(forKey: "CKUserName") ?? ""
+        
+        // Retrieve need author flag from UserDefaults
+        let isNeedAuthor = UserDefaults.standard.bool(forKey: CPDFDynamicStampNeedAuthorKey1)
+        
+        if !isNeedAuthor {
+            author = author.isEmpty ? NSFullUserName() : author
+            dateString = "By \(author) at \(dateString)"
+        }
+        
+        dynamicArray.enumerated().forEach { (idx, obj) in
+            var style: CPDFStampStyle = .red
+            
+            if idx > 0 && idx < 4 {
+                style = .green
+            }
+            
+            var stamp: CStampObject
+            
+            if idx == 4 {
+                stamp = CStampObject(dynamicText: obj, dynamicDetailText: dateString, dynamicStyle: style, needExchangeFontSize: true, dynamicShape: .rectangle)
+            } else {
+                stamp = CStampObject(dynamicText: obj, dynamicDetailText: dateString, dynamicStyle: style, needExchangeFontSize: false, dynamicShape: .rectangle)
+            }
+            
+            dynamicStampArray.append(stamp)
+        }
+        
+        return dynamicStampArray
+    }
+    
+    func addStamp(withString string: String?, categoryString: CPDFStampType, nameString: String?, dateString: String?, needExchangeFontSize: Bool, color: CPDFStampStyle, shape: CPDFStampShape, date: String?, time: String?) -> Bool {
+        if !FileManager.default.fileExists(atPath: kStampFolderPath.path) {
+            do {
+                try FileManager.default.createDirectory(atPath: kStampFolderPath.path, withIntermediateDirectories: true, attributes: nil)
+            } catch {
+                return false
+            }
+        }
+        
+        if !FileManager.default.fileExists(atPath: kStampPlistPath.path) {
+            if !FileManager.default.createFile(atPath: kStampPlistPath.path, contents: nil, attributes: nil) {
+                return false
+            }
+        }
+        
+        if var dictionary = NSDictionary(contentsOfFile: kStampPlistPath.path) as? [String: Any] {
+            var newDictionary = dictionary
+            
+            let tag = tagString()
+            var text = ""
+            var detailText = ""
+            
+            var stampDictionary: [String: Any] = [:]
+            if let string = string {
+                stampDictionary[kStampOfStringKey] = string
+                text = string
+            }
+            if let dateString = dateString {
+                stampDictionary[kStampOfSubStringKey] = dateString
+                detailText = dateString
+            }
+            if let date = date {
+                stampDictionary[kStampDateKey] = date
+            }
+            if let time = time {
+                stampDictionary[kStampTimeKey] = time
+            }
+            stampDictionary[kStampOfCategoryKey] = categoryString.rawValue
+            
+            if let nameString = nameString {
+                stampDictionary[kStampOfNameKey] = nameString
+                detailText = "\(detailText) \(nameString)"
+            }
+            stampDictionary[kStampOfColorKey] = color.rawValue
+            stampDictionary[kStampOfDateKey] = Date()
+            stampDictionary[kStampNeedExchangKey] = needExchangeFontSize ? "1" : "0"
+            
+            newDictionary[tag] = stampDictionary
+            
+            var stamp: CStampObject?
+            if categoryString == .text { // categoryString == 1
+                stamp = CStampObject(text: text, detailText: dateString ?? "", style: color, shape: shape )
+                stamp?.dateString = date ?? ""
+                stamp?.timeString = time ?? ""
+            }
+            
+            if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true), let stamp = stamp {
+                stamp.stampKey = tag
+                stamps.append(stamp)
+                return true
+            }
+        }
+        
+        return false
+    }
+    
+    func addStamp(withImagePath path: String, categoryString: CPDFStampType, nameString: String) -> Bool {
+        do {
+            if !FileManager.default.fileExists(atPath: kStampFolderPath.path) {
+                try FileManager.default.createDirectory(atPath: kStampFolderPath.path, withIntermediateDirectories: true, attributes: nil)
+            }
+            
+            if !FileManager.default.fileExists(atPath: kStampPlistPath.path) {
+                if !FileManager.default.createFile(atPath: kStampPlistPath.path, contents: nil, attributes: nil) {
+                    return false
+                }
+            }
+            
+            let tag = tagString()
+            let rPath = (kStampFolderPath.path as NSString).appendingPathComponent(tag).stringByAppendingPathExtension("jpg")
+            
+            if let image = NSImage(contentsOfFile: path) {
+                image.lockFocus()
+                let bits = NSBitmapImageRep(focusedViewRect: NSMakeRect(0, 0, image.size.width, image.size.height))
+                image.unlockFocus()
+                let imageProps = [NSBitmapImageRep.PropertyKey.compressionFactor: 0.5]
+                if let imageData = bits?.representation(using: .jpeg, properties: imageProps) {
+                    try imageData.write(to: URL(fileURLWithPath: rPath), options: .atomic)
+                } else {
+                    return false
+                }
+                
+                if var dictionary = NSDictionary(contentsOfFile: kStampPlistPath.path) as? [String: Any] {
+                    var newDictionary = dictionary
+                    
+                    let stamp = CStampObject(imageStampFilePath: rPath)
+                    stamp.nameString = nameString
+                    
+                    var stampDictionary: [String: Any] = [:]
+                    stampDictionary[kStampOfImagePathKey] = (rPath as NSString).lastPathComponent
+                    stampDictionary[kStampOfDateKey] = Date()
+                    stampDictionary[kStampOfCategoryKey] = categoryString.rawValue
+                    if !nameString.isEmpty {
+                        stampDictionary[kStampOfNameKey] = nameString
+                    }
+                    newDictionary[tag] = stampDictionary
+                    
+                    if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true) {
+                        stamp.stampKey = tag
+                        stamps.append(stamp)
+                        return true
+                    }
+                }
+            }
+        } catch {
+            return false
+        }
+        return false
+    }
+    
+    func removeStamp(_ stamp: CStampObject) -> Bool {
+        let key = stamp.stampKey
+        guard stamps.contains(stamp) else {
+            return false
+        }
+        
+        if !FileManager.default.fileExists(atPath: kStampPlistPath.path) {
+            return false
+        }
+        
+        if var dictionary = NSDictionary(contentsOfFile: kStampPlistPath.path) as? [String: Any] {
+            var newDictionary = dictionary
+            newDictionary.removeValue(forKey: key)
+            
+            if (newDictionary as NSDictionary).write(toFile: kStampPlistPath.path, atomically: true) {
+                let imagePath = stamp.imagePath
+                if imagePath.isEmpty == false {
+                    try? FileManager.default.removeItem(atPath: imagePath)
+                }
+                stamps.remove(at: stamps.firstIndex(of: stamp)!)
+                return true
+            }
+        }
+        return false
+    }
+    
+    func removeStamps(array: [CStampObject]) {
+        for object in array {
+            self.removeStamp(object)
+        }
+    }
+    
+    func addStamps(array: [CStampObject]) {
+        for object in array {
+            self.addStamp(object)
+        }
+    }
+
+    func addStamp(_ stamp: CStampObject) {
+        if stamp.stampCategoryType == .text {
+            addStamp(withString: stamp.text, categoryString: .text, nameString: "", dateString: stamp.detailText, needExchangeFontSize: false, color: stamp.style, shape: stamp.shape, date: stamp.dateString, time: stamp.timeString)
+        } else if stamp.stampCategoryType == .image {
+            addStamp(withImagePath: stamp.imagePath, categoryString: .image, nameString: "")
+        }
+    }
+    
+    func setDynamicStampDateStringWithDateStyle(_ dateStyleString: String) -> String {
+        let now = Date()
+        let formatter = DateFormatter()
+
+        switch dateStyleString {
+        case "m/d":
+            formatter.dateFormat = "M/dd HH:mm:ss"
+        case "m/d/yy":
+            formatter.dateFormat = "M/dd/yy HH:mm:ss"
+        case "m/d/yyyy":
+            formatter.dateFormat = "MM/dd/yyyy HH:mm:ss"
+        case "mm/dd/yy":
+            formatter.dateFormat = "MM/dd/yy HH:mm:ss"
+        case "mm/dd/yyyy":
+            formatter.dateFormat = "MM/dd/yyyy HH:mm:ss"
+        case "d/m/yy":
+            formatter.dateFormat = "d/M/yy HH:mm:ss"
+        case "d/m/yyyy":
+            formatter.dateFormat = "d/M/yyyy HH:mm:ss"
+        case "dd/mm/yy":
+            formatter.dateFormat = "dd/MM/yy HH:mm:ss"
+        case "dd/mm/yyyy":
+            formatter.dateFormat = "d/MM/yyyy HH:mm:ss"
+        case "mm/yy":
+            formatter.dateFormat = "MM/yy HH:mm:ss"
+        case "mm/yyyy":
+            formatter.dateFormat = "MM/yyyy HH:mm:ss"
+        case "m.d.yy":
+            formatter.dateFormat = "M.d.yy HH:mm:ss"
+        case "m.d.yyyy":
+            formatter.dateFormat = "M.d.yyyy HH:mm:ss"
+        case "mm.dd.yy":
+            formatter.dateFormat = "MM.dd.yy HH:mm:ss"
+        case "mm.dd.yyyy":
+            formatter.dateFormat = "MM.dd.yyyy HH:mm:ss"
+        case "mm.yy":
+            formatter.dateFormat = "MM.yyyy HH:mm:ss"
+        case "mm.yyyy":
+            formatter.dateFormat = "MM.yyyy HH:mm:ss"
+        case "d.m.yy":
+            formatter.dateFormat = "d.M.yy HH:mm:ss"
+        case "d.m.yyyy":
+            formatter.dateFormat = "d.M.yyyy HH:mm:ss"
+        case "dd.mm.yy":
+            formatter.dateFormat = "dd.MM.yy HH:mm:ss"
+        case "dd.mm.yyyy":
+            formatter.dateFormat = "d.MM.yyyy HH:mm:ss"
+        case "yy-mm-dd":
+            formatter.dateFormat = "yy-MM-dd HH:mm:ss"
+        case "yyyy-mm-dd":
+            formatter.dateFormat = "yyy-MM-dd HH:mm:ss"
+        default:
+            formatter.dateStyle = .medium
+            formatter.timeStyle = .short
+        }
+        
+        return formatter.string(from: now)
+    }
+
+    func dateStyleArray() -> [String] {
+        return ["m/d", "m/d/yy", "m/d/yyyy", "mm/dd/yy", "mm/dd/yyyy", "d/m/yy", "d/m/yyyy", "dd/mm/yy", "dd/mm/yyyy", "mm/yy", "mm/yyyy", "m.d.yy", "m.d.yyyy", "mm.dd.yy", "mm.dd.yyyy", "mm.yy", "mm.yyyy", "d.m.yy", "d.m.yyyy", "dd.mm.yy", "dd.mm.yyyy", "yy-mm-dd", "yyyy-mm-dd", NSLocalizedString("Default", comment: "Default")]
+    }
+}
+