Bladeren bron

【OCToSwift】NSUserDefaults+PDFListView

tangchao 1 jaar geleden
bovenliggende
commit
5233638f22

+ 0 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3270,9 +3270,6 @@
 		F34BF93529530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
 		F34BF93629530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
 		F34BF93729530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
-		F34BF949295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF948295310AB002C25A2 /* NSUserDefaults+PDFListView.m */; };
-		F34BF94A295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF948295310AB002C25A2 /* NSUserDefaults+PDFListView.m */; };
-		F34BF94B295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF948295310AB002C25A2 /* NSUserDefaults+PDFListView.m */; };
 		F34BF9532953DA91002C25A2 /* NSGeometry+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF9522953DA91002C25A2 /* NSGeometry+PDFListView.m */; };
 		F34BF9542953DA91002C25A2 /* NSGeometry+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF9522953DA91002C25A2 /* NSGeometry+PDFListView.m */; };
 		F34BF9552953DA91002C25A2 /* NSGeometry+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF9522953DA91002C25A2 /* NSGeometry+PDFListView.m */; };
@@ -4802,8 +4799,6 @@
 		F34BF925295303E8002C25A2 /* NSCursor+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSCursor+PDFListView.m"; sourceTree = "<group>"; };
 		F34BF93329530708002C25A2 /* NSImage+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSImage+PDFListView.h"; sourceTree = "<group>"; };
 		F34BF93429530708002C25A2 /* NSImage+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSImage+PDFListView.m"; sourceTree = "<group>"; };
-		F34BF947295310AB002C25A2 /* NSUserDefaults+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+PDFListView.h"; sourceTree = "<group>"; };
-		F34BF948295310AB002C25A2 /* NSUserDefaults+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSUserDefaults+PDFListView.m"; sourceTree = "<group>"; };
 		F34BF9512953DA91002C25A2 /* NSGeometry+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSGeometry+PDFListView.h"; sourceTree = "<group>"; };
 		F34BF9522953DA91002C25A2 /* NSGeometry+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSGeometry+PDFListView.m"; sourceTree = "<group>"; };
 		F356720229AF184A00740FF3 /* CPDFListAnnotationNoteWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFListAnnotationNoteWindowController.h; sourceTree = "<group>"; };
@@ -9054,8 +9049,6 @@
 				F34BF93429530708002C25A2 /* NSImage+PDFListView.m */,
 				F359921F292CA27A000D25DE /* CPDFListViewRuntime.h */,
 				F3599217292CA27A000D25DE /* CPDFListViewRuntime.m */,
-				F34BF947295310AB002C25A2 /* NSUserDefaults+PDFListView.h */,
-				F34BF948295310AB002C25A2 /* NSUserDefaults+PDFListView.m */,
 				F34BF9512953DA91002C25A2 /* NSGeometry+PDFListView.h */,
 				F34BF9522953DA91002C25A2 /* NSGeometry+PDFListView.m */,
 				F3A9DC7B294309D80074E5D2 /* CPDFListEditAnnotationViewController.h */,
@@ -10510,7 +10503,6 @@
 				899700DF28F3A9F2009AF911 /* KMHomeWindowController.swift in Sources */,
 				BB146FDE299DC0D100784A6A /* GTLRDriveObjects.m in Sources */,
 				9F0CB5112986565700007028 /* KMDesignToken+BorderRadius.swift in Sources */,
-				F34BF949295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */,
 				9F81ADC629B9B12C002251F4 /* NSButton+DesignToken.swift in Sources */,
 				BBEC00C7295C319400A26C98 /* KMBatesManager.swift in Sources */,
 				BB147020299DC0D100784A6A /* OIDServiceDiscovery.m in Sources */,
@@ -11889,7 +11881,6 @@
 				BB147012299DC0D100784A6A /* OIDError.m in Sources */,
 				9F1FE50E29407B2B00E952CA /* KMUploadFilePanel.swift in Sources */,
 				BBA93D2E29BEBAA60044E0DD /* KMPreferenceEnum.swift in Sources */,
-				F34BF94A295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */,
 				ADE8BC3F29F9458700570F89 /* KMRecommondInfo.m in Sources */,
 				89752DA02936EC50003FF08E /* KMToolbar.m in Sources */,
 				ADDEEA672AD3C4BE00EF675D /* KMPDFSignatureImageView.swift in Sources */,
@@ -12695,7 +12686,6 @@
 				89752DEC293875FC003FF08E /* KMMainToolbarController.swift in Sources */,
 				AD0E8ABB2A31BDDD00DBFD3C /* KMProduct.swift in Sources */,
 				BBC2BCC8295DA8F30036B983 /* KMCropPreviewController.swift in Sources */,
-				F34BF94B295310AB002C25A2 /* NSUserDefaults+PDFListView.m in Sources */,
 				9F1FE50F29407B2B00E952CA /* KMUploadFilePanel.swift in Sources */,
 				ADC0761C298A2E67006C752F /* KMBatchSecurityViewPresenter.swift in Sources */,
 				BB146FCB299DC0D100784A6A /* GTMSessionFetcher.m in Sources */,

+ 100 - 4
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -215,16 +215,112 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "9392A1EF-F1E1-4D7C-ABE8-BC2DECFFC286"
+            uuid = "D629E2B7-BC91-4F10-8F4C-68B3BA662969"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "582"
+            endingLineNumber = "582"
+            landmarkName = "-fetchColorsWithKey:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "4F487AE6-365E-41BB-9516-6A0A1291B103"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "567"
+            endingLineNumber = "567"
+            landmarkName = "-saveColorsWithColors:key:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "C97F14F8-C173-4C6C-9A2A-173F0C009027"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "324"
+            endingLineNumber = "324"
+            landmarkName = "setCommonlyFontColor(color:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "332"
+            endingLineNumber = "332"
+            landmarkName = "setFontAlignment(alignment:)"
+            landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 844f8b9c5ebe0774"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "332"
+                  endingLineNumber = "332"
+                  offsetFromSymbolStart = "186">
+               </Location>
+               <Location
+                  uuid = "4AA5DDA9-7119-40D7-89B4-F368372F819A - 844f8b9c5ebe0774"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Master.KMEditPDFTextManager.setFontAlignment(alignment: __C.NSTextAlignment) -&gt; ()"
+                  moduleName = "PDF Master"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "332"
+                  endingLineNumber = "332"
+                  offsetFromSymbolStart = "299">
+               </Location>
+            </Locations>
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "14F870D0-90CE-489C-9379-6B34E1A6D35A"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
             filePath = "PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "116"
-            endingLineNumber = "116"
-            landmarkName = "associatedPDListViewPointForElement(at:)"
+            startingLineNumber = "238"
+            endingLineNumber = "238"
+            landmarkName = "PDFListViewColor(forKey:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>

+ 1 - 1
PDF Office/PDF Master/Class/Home/Category/NSColor+KMExtensions.swift

@@ -81,7 +81,7 @@ public extension NSColor {
 //        }
 //        self.init(red: components.R, green: components.G, blue: components.B, alpha: components.a)
 //    }
-    
+    @objc(toHexString:)
     func toHex(alpha: Bool = false) -> String? {
         guard let components = cgColor.components, components.count >= 3 else {
             return nil

+ 0 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSCursor+PDFListView.m

@@ -14,7 +14,6 @@
 
 #import "NSImage+PDFListView.h"
 #import "CStringConstants.h"
-#import "NSUserDefaults+PDFListView.h"
 #import "CPDFListView.h"
 #import "CPDFAnnotationModel.h"
 

+ 0 - 32
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSUserDefaults+PDFListView.h

@@ -1,32 +0,0 @@
-//
-//  NSUserDefaults+PDFListView.h
-//  ComPDFKit
-//
-//  Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
-//
-//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
-//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
-//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
-//  This notice may not be removed from this file.
-//
-
-#import <Cocoa/Cocoa.h>
-#if TARGET_OS_OSX
-    #import <AppKit/AppKit.h>
-    typedef NSColor UIColor;
-#else
-    #import <UIKit/UIKit.h>
-    typedef UIColor NSColor;
-#endif
-
-@interface NSUserDefaults (PDFListView)
-
-- (NSColor *)PDFListViewColorForKey:(NSString *)key;
-
-- (void)setPDFListViewColor:(NSColor *)color forKey:(NSString *)key;
-
-
-+ (UIColor *)colorWithHexString:(NSString *)hexStr;
-+ (NSString *)hexStringWithAlphaColor:(UIColor *)color;
-+ (NSString *)hexStringWithColor:(UIColor *)color;
-@end

+ 0 - 151
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSUserDefaults+PDFListView.m

@@ -1,151 +0,0 @@
-//
-//  NSUserDefaults+PDFListView.m
-//  ComPDFKit
-//
-//  Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
-//
-//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
-//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
-//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
-//  This notice may not be removed from this file.
-//
-
-#import "NSUserDefaults+PDFListView.h"
-@implementation NSUserDefaults (PDFListView)
-
-- (NSColor *)PDFListViewColorForKey:(NSString *)key {
-    NSString *colorString = [self objectForKey:key];
-    NSColor *color;
-    if ([colorString isKindOfClass:[NSData class]]) {
-        color = [NSUnarchiver unarchiveObjectWithData:colorString];
-    } else {
-        color = [NSUserDefaults colorWithHexString:colorString];
-    }
-    NSLog(@"fetch = %@ colorString = %@",color, colorString);
-    return color;
-}
-
-- (void)setPDFListViewColor:(NSColor *)color forKey:(NSString *)key {
-    NSString *colorString = [NSUserDefaults hexStringWithAlphaColor:color];
-#if DEBUG
-//    NSLog(@"save = %@ colorString = %@",color, colorString);
-#endif
-    [self setObject:colorString forKey:key];
-    [self synchronize];
-}
-
-+ (UIColor *)colorWithHexString:(NSString *)hexStr {
-    NSString *cString = [[hexStr stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString];
-    
-    // String should be 6 or 8 characters
-    if ([cString length] < 6) {
-        return nil;
-    }
-    // 判断前缀
-    if ([cString hasPrefix:@"0X"])
-        cString = [cString substringFromIndex:2];
-    if ([cString hasPrefix:@"#"])
-        cString = [cString substringFromIndex:1];
-    if ([cString length] < 6)
-        return nil;
-    // 从六位数值中找到RGB对应的位数并转换
-    NSRange range;
-    range.location = 0;
-    range.length = 2;
-    //R、G、B
-    NSString *rString = [cString substringWithRange:range];
-    range.location = 2;
-    NSString *gString = [cString substringWithRange:range];
-    range.location = 4;
-    NSString *bString = [cString substringWithRange:range];
-    // Scan values
-    unsigned int r, g, b,a;
-    [[NSScanner scannerWithString:rString] scanHexInt:&r];
-    [[NSScanner scannerWithString:gString] scanHexInt:&g];
-    [[NSScanner scannerWithString:bString] scanHexInt:&b];
-    float alpha = 1.;
-    if ([cString length] == 8) {
-        NSString *aStr = [cString substringWithRange:NSMakeRange(6, 2)];
-        [[NSScanner scannerWithString:aStr] scanHexInt:&a];
-        alpha = a/255.;
-    }
-    return [UIColor colorWithRed:((float) r / 255.0f) green:((float) g / 255.0f) blue:((float) b / 255.0f) alpha:alpha];
-}
-
-+ (NSString *)hexStringWithAlphaColor:(UIColor *)color {
-    NSString *colorStr = [NSUserDefaults hexStringWithColor:color];
-    CGFloat a = 1.;
-#if TARGET_OS_OSX
-    a = [color alphaComponent];
-#else
-    CGFloat r,g,b;
-    [color getRed:&r green:&g blue:&b alpha:&a];
-#endif
-    NSString *alphaStr = [NSUserDefaults getHexByDecimal:a*255];
-    if (alphaStr.length < 2) {
-        alphaStr = [@"0" stringByAppendingString:alphaStr];
-    }
-    return [colorStr stringByAppendingString:alphaStr];
-}
-
-+ (NSString *)hexStringWithColor:(UIColor *)color {
-    if (!color) {
-        return nil;
-    }
-    CGFloat r,g,b,a;
-#if TARGET_OS_OSX
-    color = [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
-    r = [color redComponent];
-    g = [color greenComponent];
-    b = [color blueComponent];
-    a = [color alphaComponent];
-#else
-    [color getRed:&r green:&g blue:&b alpha:&a];
-#endif
-    
-    return [NSString stringWithFormat:@"#%@%@%@",[NSUserDefaults colorStringWithValue:r],[NSUserDefaults colorStringWithValue:g],[NSUserDefaults colorStringWithValue:b]];
-}
-
-+ (NSString *)getHexByDecimal:(NSInteger)decimal {
-    NSString *hex =@"";
-    NSString *letter;
-    NSInteger number;
-    for (int i = 0; i<9; i++) {
-        
-        number = decimal % 16;
-        decimal = decimal / 16;
-        switch (number) {
-                
-            case 10:
-                letter =@"A"; break;
-            case 11:
-                letter =@"B"; break;
-            case 12:
-                letter =@"C"; break;
-            case 13:
-                letter =@"D"; break;
-            case 14:
-                letter =@"E"; break;
-            case 15:
-                letter =@"F"; break;
-            default:
-                letter = [NSString stringWithFormat:@"%ld", number];
-        }
-        hex = [letter stringByAppendingString:hex];
-        if (decimal == 0) {
-            
-            break;
-        }
-    }
-    return hex;
-}
-
-+ (NSString *)colorStringWithValue:(CGFloat )value {
-    NSString *str = [NSUserDefaults getHexByDecimal:(NSInteger)(value*255)];
-    if (str.length < 2) {
-        return [NSString stringWithFormat:@"0%@",str];
-    }
-    return str;
-}
-
-@end

+ 45 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift

@@ -229,4 +229,49 @@ func CPDFListViewDrawFreeTextResizeHandle(_ context: CGContext, _ rect: NSRect,
     CPDFListViewDrawResizeHandle(context, NSMakePoint(NSMinX(rect), NSMidY(rect)), radius, active)
 }
 
+// MARK: - NSUserDefaults
+@objc extension UserDefaults {
+    func PDFListViewColor(forKey key: String) -> NSColor? {
+        let colorString = self.object(forKey: key) as? AnyObject
+        var color: NSColor?
+        if let data = colorString?.isKind(of: NSData.self), data {
+            color = NSUnarchiver.unarchiveObject(with: colorString as! Data) as? NSColor
+        } else {
+            if let data = colorString as? String {
+                color = NSColor.km_init(hex: data)
+            }
+        }
+        return color
+    }
+    
+    func setPDFListViewColor(_ color: NSColor, forKey key: String) {
+        let colorString = color.toHex(alpha: true)
+        self.set(colorString, forKey: key)
+        self.synchronize()
+    }
+    
+    /*
+     - (NSColor *)PDFListViewColorForKey:(NSString *)key {
+         NSString *colorString = [self objectForKey:key];
+         NSColor *color;
+         if ([colorString isKindOfClass:[NSData class]]) {
+             color = [NSUnarchiver unarchiveObjectWithData:colorString];
+         } else {
+             color = [NSUserDefaults colorWithHexString:colorString];
+         }
+         NSLog(@"fetch = %@ colorString = %@",color, colorString);
+         return color;
+     }
+
+     - (void)setPDFListViewColor:(NSColor *)color forKey:(NSString *)key {
+         NSString *colorString = [NSUserDefaults hexStringWithAlphaColor:color];
+     #if DEBUG
+     //    NSLog(@"save = %@ colorString = %@",color, colorString);
+     #endif
+         [self setObject:colorString forKey:key];
+         [self synchronize];
+     }
+     */
+}
+
 

+ 0 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m

@@ -18,7 +18,6 @@
 #import "CSelfSignAnnotation.h"
 
 #import "CStringConstants.h"
-#import "NSUserDefaults+PDFListView.h"
 
 #import <PDF_Master-Swift.h>
 

+ 4 - 3
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/NSObject/KMAnnotationPropertiesColorManager.m

@@ -6,7 +6,8 @@
 //
 
 #import "KMAnnotationPropertiesColorManager.h"
-#import "NSUserDefaults+PDFListView.h"
+#import <PDF_Master-Swift.h>
+
 NSString * KMMarkupTypeHighlightColors   = @"CPDFMarkupTypeHighlightColors";
 NSString * KMMarkupTypeOtherColors   = @"CPDFMarkupTypeOtherColors";
 NSString * KMLinePropertColors   = @"CPDFLinePropertColors";
@@ -562,7 +563,7 @@ NSString * KMSelfSignPropertColors   = @"CPDFSelfSignPropertColors";
 - (void)saveColorsWithColors:(NSArray<NSColor *> *)colors key:(NSString *)key {
     NSMutableArray * datas = [NSMutableArray array];
     for (NSColor * color in colors) {
-        NSString *hexString = [NSUserDefaults hexStringWithAlphaColor:color];
+        NSString *hexString = [color toHexString:true];
         [datas addObject:hexString];
     }
     [[NSUserDefaults standardUserDefaults] setObject:datas forKey:key];
@@ -578,7 +579,7 @@ NSString * KMSelfSignPropertColors   = @"CPDFSelfSignPropertColors";
             if ([colorString isKindOfClass:[NSData class]]) {
                 color = [NSUnarchiver unarchiveObjectWithData:colorString];
             } else {
-                color = [NSUserDefaults colorWithHexString:colorString];
+                color = [NSColor km_initWithHex:colorString alpha:1];
             }
             if (color) {
                 [colors addObject:color];

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/Manager/KMEditPDFTextManager.swift

@@ -320,7 +320,7 @@ extension KMEditPDFTextManager {
         
         let userDefaults = UserDefaults.standard
         let model = self.fetchUserDefaultData(type: .commonly)
-        let colorString: String = UserDefaults.hexString(withAlphaColor: color)
+        let colorString: String = color.toHex(alpha: true) ?? ""
         let fontDic: NSDictionary = [FONTNAME_KEY: model.fontName, FONTSIZE_KEY: model.fontSize.description, REDEFINE_KEY: model.redefine, CHANGE_KEY: model.change, COLOR_KEY: colorString, ALIGNMENT_KEY: model.alignment.rawValue]
         userDefaults.set(fontDic, forKey: Commonly_USERDEFAULTS)
         userDefaults.synchronize()
@@ -329,7 +329,7 @@ extension KMEditPDFTextManager {
     func setFontAlignment(alignment: NSTextAlignment) {
         let userDefaults = UserDefaults.standard
         let model = self.fetchUserDefaultData(type: .commonly)
-        let colorString: String = UserDefaults.hexString(withAlphaColor: model.color)
+        let colorString: String = model.color.toHex(alpha: true) ?? ""
         let fontDic: NSDictionary = [FONTNAME_KEY: model.fontName, FONTSIZE_KEY: model.fontSize.description, REDEFINE_KEY: model.redefine, CHANGE_KEY: model.change, COLOR_KEY: colorString, ALIGNMENT_KEY: alignment.rawValue]
         userDefaults.set(fontDic, forKey: Commonly_USERDEFAULTS)
         userDefaults.synchronize()
@@ -427,7 +427,7 @@ extension KMEditPDFTextManager {
     private func setTextPresupposition(fontName: String, fontSize: CGFloat, redefine: Bool = false, change: Bool = false, type: KMEditPDFTextFontType) {
         let tempFontName = self.checkFontName(fontName: fontName)
         let model = self.fetchUserDefaultData(type: type)
-        let colorString: String = UserDefaults.hexString(withAlphaColor: model.color)
+        let colorString: String = model.color.toHex(alpha: true) ?? ""
         let fontDic: NSDictionary = [FONTNAME_KEY: tempFontName, FONTSIZE_KEY: fontSize.description, REDEFINE_KEY: redefine, CHANGE_KEY: change, COLOR_KEY: colorString, ALIGNMENT_KEY: model.alignment.rawValue]
         
         let userDefaults = UserDefaults.standard
@@ -510,7 +510,7 @@ extension KMEditPDFTextManager {
         resultModel.redefine = redefine
         resultModel.change = change
         resultModel.type = type
-        resultModel.color = UserDefaults.color(withHexString: colorString)
+        resultModel.color = NSColor.km_init(hex: colorString)
         resultModel.alignment = alignment
 //        if type == .customize {
 //            resultModel.color = UserDefaults.standard.pdfListViewColor(forKey: FontColor_USERDEFAULTS) ?? NSColor.black

+ 0 - 2
PDF Office/PDF Master/PDF_Master-Bridging-Header.h

@@ -33,7 +33,6 @@
 #import "KMPDFEditAppendWindow.h"
 
 #import "KMWatermarkPDFView_OC.h"
-#import "NSUserDefaults+PDFListView.h"
 #import "KMAnnotationPropertiesColorManager.h"
 
 #import "KMCloudServer.h"
@@ -46,7 +45,6 @@
 #import "KMSelfSignAnnotationFreeText.h"
 
 #import "CStringConstants.h"
-#import "NSUserDefaults+PDFListView.h"
 
 #import "KMCellEmptyView.h"
 #import "KMSelfSignAnnotation.h"