Browse Source

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

niehaoyu 1 year ago
parent
commit
c4484135ea

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

@@ -1253,7 +1253,7 @@
                 color = [userDefaults PDFListViewColorForKey:CAnnotationChoiceWidgetFontColorKey] ? : NSColor.blackColor;
                 break;
             case CAnnotationTypeActionButton:
-                color = [userDefaults PDFListViewColorForKey:CAnnotationActionButtonWidgetFontColorKey];
+                color = [userDefaults PDFListViewColorForKey:CAnnotationActionButtonWidgetFontColorKey] ? : NSColor.blackColor;
                 break;
             default:
                 break;

+ 7 - 5
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -240,6 +240,13 @@
                 [self fromContentButtonAction:_formOptionsButton];
             }
         }
+    } else if ([annotation isKindOfClass:[KMAnnotationFromSignature class]]) {
+        KMAnnotationGeneralViewController *vc = [[KMAnnotationGeneralViewController alloc] init];
+        vc.pdfview = self.pdfView;
+        vc.annotationModel = annotationModel;
+        vc.view.frame = [self viewControllerRect];
+        [self.view addSubview:vc.view];
+        self.contentViewController = vc;
     } else if ([annotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
         KMFillSignShapePanel *vc = [[KMFillSignShapePanel alloc] init];
         vc.pdfView = self.pdfView;
@@ -506,11 +513,6 @@
                annotationMode == CAnnotationTypeComboBox ||
                annotationMode == CAnnotationTypeListMenu ||
                annotationMode == CAnnotationTypeActionButton) {
-//        KMFormPropertPanelViewController *vc = [[KMFormPropertPanelViewController alloc] init];
-//        vc.pdfView = self.pdfView;
-//        vc.annotationModel = annotationModel;
-//        self.propertiesBox.contentView = vc.view;
-//        self.contentViewController = vc;
         if (annotationMode == CAnnotationTypeTextField) {
             KMAnnotationFromViewController *vc = [[KMAnnotationFromViewController alloc] init];
             vc.pdfView = self.pdfView;

+ 16 - 26
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationButtonOptionsViewController.swift

@@ -15,7 +15,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
     private var _annotations: [CPDFButtonWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
-    var annotationModel: CPDFAnnotationModel?
+    var _annotationModel: CPDFAnnotationModel?
 
     @IBOutlet private weak var actionLabel: NSTextField!
     @IBOutlet private weak var actionLabelTextField: NSTextField!
@@ -125,7 +125,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
     
     func reloadData() {
         if annotations.count > 0 {
-            if annotation!.caption().isEmpty || annotation!.caption() == nil {
+            if annotation!.caption() == "" || annotation!.caption() == nil {
                 if let namedAction = annotation!.mouseUpAction() as? CPDFNamedAction {
                     actionLabelTextField.stringValue = NSLocalizedString("Print", comment: "")
                 } else if let urlAction = annotation!.mouseUpAction() as? CPDFURLAction {
@@ -163,7 +163,6 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
                 actionSendEmailTextField.isHidden = true
                 actionSendEmailLabel.isHidden = true
             }
-        } else {
         }
     }
     
@@ -186,7 +185,7 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
     }
     
     private func updateAnnotation() {
-        if annotationModel?.annotation != nil {
+        if annotationModel.annotation != nil {
             for tAnnotation in annotations {
                 tAnnotation.updateAppearanceStream()
                 pdfView?.setNeedsDisplayAnnotationViewFor(tAnnotation.page)
@@ -212,29 +211,21 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
         set {
             _formMode = newValue
             self.isFromMode = true
-            
-            let sud = UserDefaults.standard
-            var note: CPDFButtonWidgetAnnotation?
-            let bounds = NSMakeRect(0, 0, 60, 25)
-            var action: CPDFURLAction?
-            
-            if formMode == .actionButton {
-                if let storedCaption = sud.string(forKey: SKAnnotationActionButtonWidgetCaptionKey) {
-                    note = CPDFButtonWidgetAnnotation(document: pdfView?.document, controlType: .pushButtonControl)
-                }
-                
-                if let storedAction = sud.object(forKey: SKAnnotationActionButtonWidgetActionKey) as? CPDFURLAction {
-//                    action = storedAction
-                    note?.setMouseUpAction(action)
-                } else if let storedActionName = sud.object(forKey: SKAnnotationActionButtonWidgetActionNameKey) as? CPDFNamedAction {
-                    note?.setMouseUpAction(storedActionName)
+        }
+    }
+    
+    var annotationModel: CPDFAnnotationModel {
+        get {
+            return _annotationModel!
+        }
+        set {
+            _annotationModel = newValue
+            formMode = _annotationModel?.annotationType ?? .textField
+            if _annotationModel?.annotations != nil {
+                if annotationModel.annotations.count > 0 {
+                    annotations = annotationModel.annotations as! [CPDFButtonWidgetAnnotation]
                 }
             }
-            
-            if let note1 = note {
-                annotations = [note1]
-            }
-            annotation = note
         }
     }
     
@@ -295,7 +286,6 @@ private let LinkHyperlink = "https://www.pdfreaderpro.com"
 
     @objc func actionLabelTextFieldDidChange() {
         for tAnnotation in annotations {
-//            tAnnotation.removeAllAppearanceStreams()
             tAnnotation.setCaption(actionLabelTextField.stringValue)
         }
         updateAnnotation()    }

+ 4 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationChoiceWidgetAppearanceViewController.swift

@@ -21,7 +21,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
 
 @objcMembers class KMAnnotationChoiceWidgetAppearanceViewController: NSViewController {
     
-    private var _annotations: [CPDFChoiceWidgetAnnotation] = []
+    private var _annotations: [CPDFWidgetAnnotation] = []
     private var _formMode: CAnnotationType = .radioButton
     var pdfView: CPDFListView?
     var _annotationModel: CPDFAnnotationModel?
@@ -38,7 +38,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
     @IBOutlet private var colorPickerView: KMColorPickerView!
 
     // Properties
-    private var annotation: CPDFChoiceWidgetAnnotation?
+    private var annotation: CPDFWidgetAnnotation?
     private var isFromMode: Bool = false
     private var annotationFont: NSFont?
     private var fontWeightType: KMPDFAnnotationFontWeightType = .ultraLight
@@ -320,7 +320,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
         }
     }
 
-    var annotations: [CPDFChoiceWidgetAnnotation] {
+    var annotations: [CPDFWidgetAnnotation] {
         get {
             return _annotations
         }
@@ -339,7 +339,7 @@ private enum KMPDFAnnotationFontWeightType: Int {
             formMode = _annotationModel?.annotationType ?? .textField
             if _annotationModel?.annotations != nil {
                 if annotationModel.annotations.count > 0 {
-                    annotations = annotationModel.annotations as! [CPDFChoiceWidgetAnnotation]
+                    annotations = annotationModel.annotations as! [CPDFWidgetAnnotation]
                 }
             }
         }

+ 0 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/ViewController/FormProperties/KMAnnotationFromViewController.swift

@@ -469,7 +469,6 @@ import Cocoa
     @IBAction func currentFontColorButtonAction(_ sender: NSButton) {
         if let color = colorWithCGColor(sender.layer?.backgroundColor) {
             for tAnnotation in annotations {
-//                tAnnotation.removeAllAppearanceStreams()
                 tAnnotation.fontColor = color
             }
             updateAnnotation()

+ 4 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/KMRightSideViewController.swift

@@ -85,6 +85,10 @@ class KMRightSideViewController: NSViewController,CipherTextViewDelegate {
                 self.annotationProperties.isEmptyAnnotation = true
                 return
             }
+        } else if (selectedAnnotation is KMAnnotationFromSignature) && (activeAnnotations.count > 1) {
+            self.annotationProperties.annotations = []
+            self.annotationProperties.isEmptyAnnotation = true
+            return
         }
        
         let annotationType = pdfView.annotationType