Browse Source

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

tangchao 11 months ago
parent
commit
6dc5f3abaa

+ 22 - 3
PDF Office/PDF Master/Class/PDFTools/AddPassword/New/KMSecurityWindowController.swift

@@ -15,6 +15,25 @@ class KMSecurityWindowController: KMBaseWindowController {
     var batchAction: KMBatchActionBlock?
     var doneAction: KMSecurityWindowControllerDoneAction?
     
+    
+    var documentURL: URL? //{
+//        didSet{
+//            if self.password.count != 0 {
+//                self.securityView.documentURL = self.documentURL
+//            } else {
+//                KMBaseWindowController.checkPassword(url: documentURL, type: .owner) { [unowned self] success, paasswordString in
+//                    if success {
+//                        self.securityView.documentURL = self.documentURL
+//                    } else {
+//                        guard let callBack = self.itemClick else { return }
+//                        
+//                        callBack()
+//                    }
+//                }
+//            }
+//        }
+//    }
+    
     override func windowDidLoad() {
         super.windowDidLoad()
 
@@ -26,7 +45,7 @@ class KMSecurityWindowController: KMBaseWindowController {
         securityView.batchAction = { [unowned self] view, files in
             if files.count == 0 {
                 let file: KMFileAttribute = KMFileAttribute()
-                file.filePath = self.pdfDocument?.documentURL.path ?? ""
+                file.filePath = self.documentURL?.path ?? self.pdfDocument?.documentURL.path ?? ""
                 self.batchAction?(self, [file])
             } else {
                 self.batchAction?(self, files)
@@ -41,12 +60,12 @@ class KMSecurityWindowController: KMBaseWindowController {
 
 extension KMSecurityWindowController {
     func setPassword(model: KMSecureEncryptModel, files: [KMFileAttribute]) {
-        if pdfDocument == nil {
+        if pdfDocument == nil && documentURL == nil{
             guard let filePath = files.first?.filePath else { return }
         }
         
 //        let myDocument = CPDFDocument(url: NSURL(fileURLWithPath: filePath) as URL)
-        if (pdfDocument != nil) {
+        if (pdfDocument != nil || documentURL != nil) {
             var options: [CPDFDocumentWriteOption : Any] = [:]
             var attribute: [CPDFDocumentAttribute : Any] = [:]
             if model.openPasswordOn && model.ownerPasswordOn { ///  开启密码 & 权限密码

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

@@ -1438,7 +1438,7 @@ let LOCKED_KEY  = "locked"
     
     public func showSecureWindow(_ url: URL) {
         let controller = KMSecurityWindowController(windowNibName: "KMSecurityWindowController")
-        controller.pdfDocument = self.document
+        controller.documentURL = self.listView.document.documentURL
         self.currentWindowController = controller
 
         controller.batchAction = { [unowned self] controller, files in
@@ -1449,7 +1449,7 @@ let LOCKED_KEY  = "locked"
 
             let batchWindowController = KMBatchOperateWindowController.sharedWindowController
 //            batchWindowController.window?.makeKeyAndOrderFront("")
-            let batchOperateFile = KMBatchOperateFile(filePath: files.first?.filePath ?? "", type: .AddPassword)
+            let batchOperateFile = KMBatchOperateFile(filePath: self.document?.documentURL.path ?? "", type: .AddPassword)
             batchWindowController.switchToOperateType(.AddPassword, files: [batchOperateFile])
             batchWindowController.window?.makeKeyAndOrderFront("")
         }