فهرست منبع

【2025】【Edit】文本模块预设初步调整

niehaoyu 2 ماه پیش
والد
کامیت
dcb5e45eec

+ 96 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFEditArea/CPDFEditTextArea_Extension.swift

@@ -0,0 +1,96 @@
+//
+//  CPDFEditTextArea_Extension.swift
+//  PDF Reader Pro
+//
+//  Created by kdanmobile on 2025/1/23.
+//
+
+import Foundation
+
+//MARK: - DefaultInfo
+extension CPDFEditTextArea {
+    
+    class func defaultFontName() -> String {
+        if let string = CPDFAnnotationConfig.getDefaultStringValue(forKey: CFreeTextNoteFontNameKey) {
+            return string
+        }
+        return "Helvetica"
+    }
+    
+    class func defaultFontStyle() -> String {
+        if let string = CPDFAnnotationConfig.getDefaultStringValue(forKey: CFreeTextNoteFontStyleKey) {
+            return string
+        }
+        return "Regular"
+    }
+    
+    class func defaultFontSize() -> CGFloat {
+        return CPDFAnnotationConfig.getDefaultFloatValue(forKey: CFreeTextNoteFontSizeKey) ?? 12
+    }
+    
+    class func defaultFontAlignment() -> NSTextAlignment {
+        if let styleKey = CPDFAnnotationConfig.getDefaultIntValue(forKey: CFreeTextNoteAlignmentKey) {
+            let style: NSTextAlignment = NSTextAlignment(rawValue: styleKey) ?? .left
+            return style
+        }
+        return .left
+    }
+    
+    class func defaultIsBold() -> Bool {
+        return false
+    }
+    
+    class func defaultIsItality() -> Bool {
+        return false
+    }
+    
+    class func defaultColor() -> NSColor {
+        if let value = CPDFAnnotationConfig.getDefaultColor(forKey: CPDFEditTextArea_DefaultColorKey) {
+            return value
+        }
+        return NSColor(red: 0, green: 0, blue: 0, alpha: 1)
+    }
+    
+    class func defaultOpacity() -> CGFloat {
+        return CPDFAnnotationConfig.getDefaultFloatValue(forKey: CPDFEditTextArea_DefaultOpacityKey) ?? 1
+    }
+    
+    
+}
+
+//MARK: - Update DefaultInfo
+extension CPDFEditTextArea {
+    class func update_DefaultFont_Info(_ cfont: CPDFFont) {
+        CPDFAnnotationConfig.setDefaultStringValue(cfont.familyName, toKey: CFreeTextNoteFontNameKey)
+        if let styleName = cfont.styleName {
+            CPDFAnnotationConfig.setDefaultStringValue(styleName, toKey: CFreeTextNoteFontStyleKey)
+        }
+    }
+    
+    class func update_DefaultFontSize_Info(_ size: CGFloat) {
+        CPDFAnnotationConfig.setDefaultFloatValue(size, toKey: CFreeTextNoteFontSizeKey)
+    }
+    
+    class func update_DefaultFontAlignment_Info(_ alignment: NSTextAlignment) {
+        CPDFAnnotationConfig.setDefaultIntValue(alignment.rawValue, toKey: CFreeTextNoteAlignmentKey)
+    }
+    
+    class func update_DefaultFontBold(_ bold: Bool) {
+  
+    }
+     
+    class func update_DefaultFontItality(_ itality: Bool) {
+  
+    }
+    
+    class func updateDefault_Color(_ color: NSColor?) {
+        guard let resultColor = color else {
+            return
+        }
+        CPDFAnnotationConfig.setDefaultColor(resultColor, toKey: CPDFEditTextArea_DefaultColorKey)
+    }
+
+    class func updateDefault_Opacity(_ opacity: CGFloat) {
+        CPDFAnnotationConfig.setDefaultFloatValue(opacity, toKey: CPDFEditTextArea_DefaultOpacityKey)
+    }
+}

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFTextAnnotation+PDFListView.swift

@@ -134,7 +134,7 @@ extension CPDFTextAnnotation {
 //MARK: - DefaultInfo
 extension CPDFTextAnnotation {
     class func defaultColor() -> NSColor {
-        if let value = CPDFAnnotationConfig.getDefaultColor(forKey: CInkNoteColorKey) {
+        if let value = CPDFAnnotationConfig.getDefaultColor(forKey: CAnchoredNoteColorKey) {
             return value
         }
         return NSColor(red: 255/255.0, green: 126/255.0, blue: 126/255.0, alpha: 1)
@@ -152,7 +152,7 @@ extension CPDFTextAnnotation {
         guard let resultColor = color else {
             return
         }
-        CPDFAnnotationConfig.setDefaultColor(resultColor, toKey: CInkNoteColorKey)
+        CPDFAnnotationConfig.setDefaultColor(resultColor, toKey: CAnchoredNoteColorKey)
     }
     
     class func updateDefaultIconType(_ type: CPDFTextAnnotationIconType) {

+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CStringConstants.h

@@ -286,6 +286,9 @@ extern NSString *CMeasureRectanglesFontSizeKey;
 extern NSString *CMeasureRectanglesDisplayLengthKey;
 extern NSString *CMeasureRectanglesDisplayAreaKey;
  
+//MARK: - Edit_Text
+extern NSString *CPDFEditTextArea_DefaultColorKey;
+extern NSString *CPDFEditTextArea_DefaultOpacityKey;
 
 //MARK: -待删除项
 extern NSString *CAnnotationTextWidgetLineWidthKey;

+ 4 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CStringConstants.m

@@ -288,6 +288,10 @@ NSString *CMeasureRectanglesFontSizeKey    = @"CMeasureRectanglesFontSizeKey";
 NSString *CMeasureRectanglesDisplayLengthKey = @"CMeasureRectanglesDisplayLengthKey";
 NSString *CMeasureRectanglesDisplayAreaKey   = @"CMeasureRectanglesDisplayAreaKey";
 
+//MARK: - Edit_Text
+NSString *CPDFEditTextArea_DefaultColorKey   = @"CPDFEditTextArea_DefaultColorKey";
+NSString *CPDFEditTextArea_DefaultOpacityKey = @"CPDFEditTextArea_DefaultOpacityKey";
+
 //待删除
 NSString *CAnnotationTextWidgetLineWidthKey = @"CAnnotationTextWidgetLineWidthKey";
 

+ 11 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/EditPDF/KMEditPDFTextPropertyViewController.swift

@@ -210,6 +210,7 @@ class KMEditPDFTextPropertyViewController: NSViewController {
                 
                 currentAreaChanged()
             }
+            alignmentBGView.isHidden = true
         } else if areas.count == 1 {
             if let area = areas.first, currentArea != area {
                 currentArea = area
@@ -273,6 +274,11 @@ class KMEditPDFTextPropertyViewController: NSViewController {
                     opacity = value
                 }
             }
+        } else {
+            
+            color = CPDFEditTextArea.defaultColor()
+            
+            opacity = CPDFEditTextArea.defaultOpacity()
         }
         
         if areas.count > 1 {
@@ -558,6 +564,7 @@ extension KMEditPDFTextPropertyViewController: ComponentSelectDelegate {
             } else if view == colorOpacitySelect {
                 let opacity = max(0, min(1, result.stringToCGFloat()/100))
                 pdfView?.setEditingAreasOpacity(opacity)
+                CPDFEditTextArea.updateDefault_Opacity(opacity)
             }
         }
         reloadData()
@@ -576,6 +583,7 @@ extension KMEditPDFTextPropertyViewController: ComponentSelectDelegate {
             } else if view == colorOpacitySelect {
                 let opacity = max(0, min(1, result.stringToCGFloat()/100))
                 pdfView?.setEditingAreasOpacity(opacity)
+                CPDFEditTextArea.updateDefault_Opacity(opacity)
             }
         }
         
@@ -590,6 +598,8 @@ extension KMEditPDFTextPropertyViewController: ComponentCColorDelegate {
     func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
         if view == colorGroup {
             pdfView?.changeEditingTextarea_Color(color: color)
+            
+            CPDFEditTextArea.updateDefault_Color(color)
         }
     }
 }
@@ -600,6 +610,7 @@ extension KMEditPDFTextPropertyViewController: ComponentSliderDelegate {
         let percent = view.properties.percent
         
         self.pdfView?.setEditingAreasOpacity(percent)
+        CPDFEditTextArea.updateDefault_Opacity(percent)
         
         reloadData()
         

+ 8 - 0
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -3358,6 +3358,9 @@
 		BB8D52A52BA29A5C00D5CB31 /* SKVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8D52A32BA29A5C00D5CB31 /* SKVersionNumber.m */; };
 		BB8D52A62BA29A5C00D5CB31 /* SKVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8D52A32BA29A5C00D5CB31 /* SKVersionNumber.m */; };
 		BB8D52A72BA29A5C00D5CB31 /* SKVersionNumber.m in Sources */ = {isa = PBXBuildFile; fileRef = BB8D52A32BA29A5C00D5CB31 /* SKVersionNumber.m */; };
+		BB8D71212D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8D71202D42570700C2309A /* CPDFEditTextArea_Extension.swift */; };
+		BB8D71222D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8D71202D42570700C2309A /* CPDFEditTextArea_Extension.swift */; };
+		BB8D71232D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8D71202D42570700C2309A /* CPDFEditTextArea_Extension.swift */; };
 		BB8F4560295AA39F0037EA22 /* KMHeaderFooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F455F295AA39F0037EA22 /* KMHeaderFooterModel.swift */; };
 		BB8F4561295AA39F0037EA22 /* KMHeaderFooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F455F295AA39F0037EA22 /* KMHeaderFooterModel.swift */; };
 		BB8F4562295AA39F0037EA22 /* KMHeaderFooterModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB8F455F295AA39F0037EA22 /* KMHeaderFooterModel.swift */; };
@@ -5979,6 +5982,7 @@
 		BB8B173B2907CDD8001C5EA5 /* NibLoadable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NibLoadable.swift; sourceTree = "<group>"; };
 		BB8D52A32BA29A5C00D5CB31 /* SKVersionNumber.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SKVersionNumber.m; sourceTree = "<group>"; };
 		BB8D52A42BA29A5C00D5CB31 /* SKVersionNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKVersionNumber.h; sourceTree = "<group>"; };
+		BB8D71202D42570700C2309A /* CPDFEditTextArea_Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPDFEditTextArea_Extension.swift; sourceTree = "<group>"; };
 		BB8F455F295AA39F0037EA22 /* KMHeaderFooterModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMHeaderFooterModel.swift; sourceTree = "<group>"; };
 		BB8F4564295AA3ED0037EA22 /* KMHeaderFooterManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMHeaderFooterManager.swift; sourceTree = "<group>"; };
 		BB90E4ED2AF3546500B04B9F /* NSUserDefaultsController+KMExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "NSUserDefaultsController+KMExtension.swift"; sourceTree = "<group>"; };
@@ -9693,6 +9697,7 @@
 			children = (
 				BB96C4282CE6DDB2003F3668 /* CPDFListView+CPDFEditArea.swift */,
 				BB0B305E2D098AD8003F54D3 /* CPDFEditArea_Extension.swift */,
+				BB8D71202D42570700C2309A /* CPDFEditTextArea_Extension.swift */,
 			);
 			path = CPDFEditArea;
 			sourceTree = "<group>";
@@ -14693,6 +14698,7 @@
 				BB91383F2CEE08C100BAB4A7 /* KMCropPropertyController.swift in Sources */,
 				9F1FE50529406E4700E952CA /* CTTabStripDragController.m in Sources */,
 				65B143AA2CF06B97001B5A69 /* NSColor+KMExtensions.swift in Sources */,
+				BB8D71212D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */,
 				BBA9222B2B4E96450061057A /* KMPurchaseCompareWindowController.m in Sources */,
 				9F1FE4CF29406E4700E952CA /* CTTabController.m in Sources */,
 				ADD3EC002D13F23D005B711B /* KMOCRController.swift in Sources */,
@@ -16187,6 +16193,7 @@
 				BB451A7B2CF59EBC003E1565 /* KMHighlightController.swift in Sources */,
 				653647C32CDCA5DE00CDB13E /* KMBatchOperateLeftViewController.swift in Sources */,
 				9FCFEC9D2AD152FA00EAD2CB /* CustomAlertView.swift in Sources */,
+				BB8D71222D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */,
 				65C404322CFDA62500B32BDC /* KMNSearchReplaceItemView.swift in Sources */,
 				BB42A5D92B8F0F840092C524 /* KMTabbingHintWindowController.swift in Sources */,
 				BB67EE1B2B54FFEF00573BF0 /* ASIHTTPRequest.m in Sources */,
@@ -17036,6 +17043,7 @@
 				AD1FE82E2BD7C98300AA4A9B /* KMPDFBookletWindowController.m in Sources */,
 				BB67EE1F2B54FFEF00573BF0 /* ASIFormDataRequest.m in Sources */,
 				ADDF838B2B391A5D00A81A4E /* DSignatureFileListCellView.swift in Sources */,
+				BB8D71232D42570700C2309A /* CPDFEditTextArea_Extension.swift in Sources */,
 				BB46CF4E2AFBB34900281EDF /* AutoSaveManager.swift in Sources */,
 				ADD1B6BD29420B4A00C3FFF7 /* KMPrintPreviewView.swift in Sources */,
 				651675D52CE3312000019A20 /* KMBOTAOutlineRowView.swift in Sources */,