Parcourir la source

【综合】签名&填写表单 添加不上个人信息表单(已修复)

tangchao il y a 1 an
Parent
commit
c17da1f975

+ 54 - 0
PDF Office/PDF Master/Class/Common/Category/CPDFKit/CPDFView+KMExtension.swift

@@ -26,5 +26,59 @@ import Foundation
     @objc func allowsNotes() -> Bool {
         return self.document?.allowsNotes() ?? false
     }
+}
+
+@objc extension CPDFListView {
+    @objc func addTextField(subType: KMSelfSignAnnotationFreeTextSubType, string: String) {
+//        NSPoint center = [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil];
+        let point = self.window?.mouseLocationOutsideOfEventStream ?? .zero
+        let fromView: NSView? = nil
+        let center = self.convert(point, from: fromView)
+        self.addTextField(center: center, subType: subType, string: string)
+    }
     
+    @objc func addTextField(center: NSPoint, subType: KMSelfSignAnnotationFreeTextSubType, string: String) {
+        var page: CPDFPage?
+        var bounds: NSRect = .zero
+        var selection = self.currentSelection
+        page = selection?.safeFirstPage()
+        
+        var centerP = center
+//        page = NSMouseInRect(center, [self visibleContentRect], [self isFlipped]) ? [self pageForPoint:center nearest:NO] : nil;
+        if NSMouseInRect(center, self.visibleContentRect(), self.isFlipped) {
+            page = self.page(for: center, nearest: false)
+        } else {
+            page = nil
+        }
+        if (page == nil) {
+            var viewFrame = self.frame
+            centerP = KMCenterPoint(viewFrame)
+            page = self.page(for: centerP, nearest: true)
+            if (page == nil) {
+                page = self.currentPage()
+                centerP = self.convert(KMCenterPoint(page?.bounds(for: self.displayBox) ?? .zero), from: page)
+            }
+        }
+
+        let defaultWidth: CGFloat = 200
+        let defaultHeight: CGFloat = 100
+//        NSSize defaultSize = ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
+        let defaultSize = ((page?.rotation ?? 0) % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight, defaultWidth)
+
+        centerP = KMIntegralPoint(self.convert(centerP, to: page))
+        bounds = KMRectFromCenterAndSize(center: centerP, size: defaultSize)
+        bounds = KMConstrainRect(rect: bounds, boundary: page?.bounds(for: self.displayBox) ?? .zero)
+        if (page != nil) {
+//            KMSelfSignAnnotationFreeText *annotation = [[KMSelfSignAnnotationFreeText alloc] initSkimNoteWithBounds:bounds subType:subType string:string];
+            let annotation = KMSelfSignAnnotationFreeText(document: self.document, subType: subType, string: string, bounds: bounds)
+            let date = Date()
+            annotation.setModificationDate(date)
+            annotation.registerUserName()
+            self.addAnnotation(with: annotation, to: page)
+//            [self setActiveAnnotation:annotation];
+            self.updateActiveAnnotations([annotation])
+        } else {
+            NSSound.beep()
+        }
+    }
 }

+ 24 - 36
PDF Office/PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift

@@ -7,7 +7,7 @@
 
 import Cocoa
 
-class KMProfileInfoWindowController: NSWindowController {
+class KMProfileInfoWindowController: KMBaseWindowController {
     var callBack: ((String) -> Void)?
     
     @IBOutlet var titleLabel: NSTextField!
@@ -22,11 +22,6 @@ class KMProfileInfoWindowController: NSWindowController {
     
     private let TitleCellIdentifier = "TitleCell"
     private let NormalCellIdentifier = "Normal"
-
-    deinit {
-        KMPrint("KMProfileInfoWindowController deinit.")
-        DistributedNotificationCenter.default().removeObserver(self)
-    }
     
     override func windowDidLoad() {
         super.windowDidLoad()
@@ -34,7 +29,6 @@ class KMProfileInfoWindowController: NSWindowController {
         self._configuViews()
         self._fetchDisplayKeys()
         self.tableView.reloadData()
-        DistributedNotificationCenter.default().addObserver(self, selector: #selector(_themeChanged), name: NSNotification.Name("AppleInterfaceThemeChangedNotification"), object: nil)
     }
     
     @IBAction func addFileName_Add(_ sender: NSButton) {
@@ -172,6 +166,14 @@ class KMProfileInfoWindowController: NSWindowController {
         self._fetchDisplayKeys()
         self.tableView.reloadData()
     }
+    
+    override func interfaceThemeDidChanged(_ appearance: NSAppearance.Name) {
+        super.interfaceThemeDidChanged(appearance)
+        
+        DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
+            self._updateViewColor()
+        }
+    }
 }
 
 // MARK: - Private Methods
@@ -230,12 +232,6 @@ extension KMProfileInfoWindowController {
         }
     }
     
-    @objc private func _themeChanged(_ notification: NSNotification) {
-        DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
-            self._updateViewColor()
-        }
-    }
-    
     private func _updateViewColor() {
         self.tableView.reloadData()
     }
@@ -356,7 +352,6 @@ extension KMProfileInfoWindowController: NSTableViewDelegate, NSTableViewDataSou
             cellView?.textField?.textColor = KMAppearance.Layout.h0Color()
             if (customIndex > row) {
                 cellView?.detailtextField.tag = row
-//                [self configuTextField:cellView];
                 self._configuTextField(cellView)
                 cellView?.textField?.isEditable = false
                 cellView?.textField?.isSelectable = false
@@ -434,39 +429,39 @@ extension KMProfileInfoWindowController: NSTextFieldDelegate {
         }
         let cellView = self.tableView.view(atColumn: 0, row: currentRow, makeIfNecessary: false) as? KMProfileCellView
         if (currentRow == 1) {
-            KMProfileInfo.shared().fullName = textField.stringValue;
+            KMProfileInfo.shared().fullName = textField.stringValue
         } else if (currentRow == 2) {
-            KMProfileInfo.shared().firstName = textField.stringValue;
+            KMProfileInfo.shared().firstName = textField.stringValue
         } else if (currentRow == 3) {
-            KMProfileInfo.shared().middleName = textField.stringValue;
+            KMProfileInfo.shared().middleName = textField.stringValue
         } else if (currentRow == 4) {
-            KMProfileInfo.shared().lastName = textField.stringValue;
+            KMProfileInfo.shared().lastName = textField.stringValue
         } else if (currentRow == 6) {
-            KMProfileInfo.shared().street1 = textField.stringValue;
+            KMProfileInfo.shared().street1 = textField.stringValue
         } else if (currentRow == 7) {
-            KMProfileInfo.shared().street2 = textField.stringValue;
+            KMProfileInfo.shared().street2 = textField.stringValue
         } else if (currentRow == 8) {
-            KMProfileInfo.shared().city = textField.stringValue;
+            KMProfileInfo.shared().city = textField.stringValue
         } else if (currentRow == 9) {
-            KMProfileInfo.shared().state = textField.stringValue;
+            KMProfileInfo.shared().state = textField.stringValue
         } else if (currentRow == 10) {
-            KMProfileInfo.shared().zip = textField.stringValue;
+            KMProfileInfo.shared().zip = textField.stringValue
         } else if (currentRow == 11) {
-            KMProfileInfo.shared().country = textField.stringValue;
+            KMProfileInfo.shared().country = textField.stringValue
         } else if (currentRow == 13) {
-            KMProfileInfo.shared().email = textField.stringValue;
+            KMProfileInfo.shared().email = textField.stringValue
         } else if (currentRow == 14) {
-            KMProfileInfo.shared().tel = textField.stringValue;
+            KMProfileInfo.shared().tel = textField.stringValue
         } else if (currentRow == 16) {
     //        [KMProfileInfo.shared().date = textField.stringValue;
         } else if (currentRow == 17) {
-            KMProfileInfo.shared().birthDate = textField.stringValue;
+            KMProfileInfo.shared().birthDate = textField.stringValue
         } else if (currentRow >= 19 ) {
             let customIndex = currentRow - 19
             if (cellView != nil) {
                 let dict = KMProfileInfo.shared().customInfoArray[customIndex] as? [String : Any]
-                let originalKey = dict?.keys.first!
-                let originalValue = dict?.values.first as! String
+                let originalKey = dict?.keys.first ?? ""
+                let originalValue = dict?.values.first as? String ?? ""
                 if textField.isEqual(cellView?.textField) {
                     let newDict = [textField.stringValue : originalValue]
                     KMProfileInfo.shared().replaceObjectInCustomInfoArray(at: customIndex, with: newDict)
@@ -486,13 +481,6 @@ extension KMProfileInfoWindowController: NSTextFieldDelegate {
     
     func controlTextDidBeginEditing(_ obj: Notification) {
          let textField = obj.object as? NSTextField
-//        BOOL isDarkMode = NO;
-//        if (@available(macOS 10.14, *)) {
-//            if ([[NSApplication sharedApplication].effectiveAppearance isEqual: [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua]]) {
-//                isDarkMode =YES;
-//            }
-//        }
-
         textField?.textColor = NSColor.labelColor
     }
     

+ 3 - 3
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -4514,9 +4514,9 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     Swift.debugPrint("KMToolbarToolProfileIdentifier ...")
                     let windowC = KMProfileInfoWindowController(windowNibName: "KMProfileInfoWindowController")
                     windowC.callBack = { [weak self] string in
-//                        if (string.length > 0) {
-//                            [blockSelf.pdfView addTextFieldWithSubType:KMSelfSignAnnotationFreeTextSubType_Profile string:string];
-//                        }
+                        if (string.isEmpty == false) {
+                            self?.listView.addTextField(subType: .profile, string: string)
+                        }
                         self?.km_endSheet()
                     }
                     self.km_beginSheet(windowC: windowC)

+ 150 - 22
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -289,36 +289,132 @@
             endingLineNumber = "3907"
             landmarkName = "clickChildTool(type:index:)"
             landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "80B5B3FF-8C4D-4A21-ADEC-AD848598BDB2"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "947"
+            endingLineNumber = "947"
+            landmarkName = "autoCropAll(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "1080823F-C977-4741-9812-7C251C2DA0D9"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "952"
+            endingLineNumber = "952"
+            landmarkName = "smartAutoCropAll(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "1B724864-6ED6-4C1D-8CA3-F8E26F1E5D51"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "46"
+            endingLineNumber = "46"
+            landmarkName = "buttonClicked_back(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "C549DF0E-AC2F-49D4-B2A1-413F74F8AA22"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "63"
+            endingLineNumber = "63"
+            landmarkName = "buttonClicked_addNewInfo(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "2EE1ADB4-7259-4E8C-A65B-9D661FD534A6"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "79"
+            endingLineNumber = "79"
+            landmarkName = "buttonClicked_RemoveNewInfo(_:)"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "420D08E5-EF45-4277-8829-126645D63C25"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "92"
+            endingLineNumber = "92"
+            landmarkName = "menuItemClicked_Edit(_:)"
+            landmarkType = "7">
             <Locations>
                <Location
-                  uuid = "704A9D07-43BC-4F2B-8466-823716A7A94F - 5fcfd7af54748df2"
+                  uuid = "420D08E5-EF45-4277-8829-126645D63C25 - dd4e5e6c912185a9"
                   shouldBeEnabled = "Yes"
                   ignoreCount = "0"
                   continueAfterRunningActions = "No"
-                  symbolName = "closure #7 (__C.NSWindowController, PDF_Reaer_Pro.KMHeaderFooterModel) -&gt; () in closure #1 @Sendable () async -&gt; () in PDF_Reaer_Pro.KMMainViewController.clickChildTool(type: PDF_Reaer_Pro.KMToolbarType, index: Swift.Int) -&gt; ()"
+                  symbolName = "PDF_Reaer_Pro.KMProfileInfoWindowController.menuItemClicked_Edit(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
                   moduleName = "PDF Reaer Pro"
                   usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
                   startingColumnNumber = "9223372036854775807"
                   endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "3907"
-                  endingLineNumber = "3907"
-                  offsetFromSymbolStart = "219">
+                  startingLineNumber = "92"
+                  endingLineNumber = "92"
+                  offsetFromSymbolStart = "171">
                </Location>
                <Location
-                  uuid = "704A9D07-43BC-4F2B-8466-823716A7A94F - 5fcfd7af54748df2"
+                  uuid = "420D08E5-EF45-4277-8829-126645D63C25 - dd4e5e6c912185a9"
                   shouldBeEnabled = "Yes"
                   ignoreCount = "0"
                   continueAfterRunningActions = "No"
-                  symbolName = "closure #7 (__C.NSWindowController, PDF_Reaer_Pro.KMHeaderFooterModel) -&gt; () in closure #1 @Sendable () async -&gt; () in PDF_Reaer_Pro.KMMainViewController.clickChildTool(type: PDF_Reaer_Pro.KMToolbarType, index: Swift.Int) -&gt; ()"
+                  symbolName = "PDF_Reaer_Pro.KMProfileInfoWindowController.menuItemClicked_Edit(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
                   moduleName = "PDF Reaer Pro"
                   usesParentBreakpointCondition = "Yes"
-                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
                   startingColumnNumber = "9223372036854775807"
                   endingColumnNumber = "9223372036854775807"
-                  startingLineNumber = "3907"
-                  endingLineNumber = "3907"
-                  offsetFromSymbolStart = "288">
+                  startingLineNumber = "92"
+                  endingLineNumber = "92"
+                  offsetFromSymbolStart = "653">
                </Location>
             </Locations>
          </BreakpointContent>
@@ -326,32 +422,64 @@
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "80B5B3FF-8C4D-4A21-ADEC-AD848598BDB2"
+            uuid = "9D5FA5F4-0720-42EF-B7B2-1D04CEE324CD"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "947"
-            endingLineNumber = "947"
-            landmarkName = "autoCropAll(_:)"
+            startingLineNumber = "107"
+            endingLineNumber = "107"
+            landmarkName = "menuItemClicked_Add(_:)"
             landmarkType = "7">
+            <Locations>
+               <Location
+                  uuid = "9D5FA5F4-0720-42EF-B7B2-1D04CEE324CD - 9c3d353f930d7421"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reaer_Pro.KMProfileInfoWindowController.menuItemClicked_Add(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reaer Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "107"
+                  endingLineNumber = "107"
+                  offsetFromSymbolStart = "81">
+               </Location>
+               <Location
+                  uuid = "9D5FA5F4-0720-42EF-B7B2-1D04CEE324CD - 9c3d353f930d7421"
+                  shouldBeEnabled = "Yes"
+                  ignoreCount = "0"
+                  continueAfterRunningActions = "No"
+                  symbolName = "PDF_Reaer_Pro.KMProfileInfoWindowController.menuItemClicked_Add(Swift.Optional&lt;Swift.AnyObject&gt;) -&gt; ()"
+                  moduleName = "PDF Reaer Pro"
+                  usesParentBreakpointCondition = "Yes"
+                  urlString = "file:///Users/kdanmobile/work/tangchao/git/PDFOffice/PDF%20Office/PDF%20Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
+                  startingColumnNumber = "9223372036854775807"
+                  endingColumnNumber = "9223372036854775807"
+                  startingLineNumber = "107"
+                  endingLineNumber = "107"
+                  offsetFromSymbolStart = "523">
+               </Location>
+            </Locations>
          </BreakpointContent>
       </BreakpointProxy>
       <BreakpointProxy
          BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
          <BreakpointContent
-            uuid = "1080823F-C977-4741-9812-7C251C2DA0D9"
+            uuid = "F8ED6208-846A-4FF3-9BAC-C82C0A0BB7B2"
             shouldBeEnabled = "Yes"
             ignoreCount = "0"
             continueAfterRunningActions = "No"
-            filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift"
+            filePath = "PDF Master/Class/PDFTools/SelfSign/Window/KMProfileInfoWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "952"
-            endingLineNumber = "952"
-            landmarkName = "smartAutoCropAll(_:)"
+            startingLineNumber = "114"
+            endingLineNumber = "114"
+            landmarkName = "menuItemClicked_Delete(_:)"
             landmarkType = "7">
          </BreakpointContent>
       </BreakpointProxy>