|
@@ -3438,58 +3438,99 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
|
|
self.showSecureWindow(self.listView.document.documentURL)
|
|
self.showSecureWindow(self.listView.document.documentURL)
|
|
return
|
|
return
|
|
} else if index == 2 {
|
|
} else if index == 2 {
|
|
- let controller = KMRemovePasswordWindowController(windowNibName: "KMRemovePasswordWindowController")
|
|
|
|
- controller.pdfDocument = self.document
|
|
|
|
- self.currentWindowController = controller
|
|
|
|
-
|
|
|
|
- controller.batchAction = { [unowned self] controller, files in
|
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
- self.currentWindowController = nil
|
|
|
|
|
|
+ if !self.document!.allowsCopying || !self.document!.allowsPrinting {
|
|
|
|
+ let alert = NSAlert()
|
|
|
|
+ alert.alertStyle = .warning
|
|
|
|
+ alert.messageText = NSLocalizedString("Warning", comment: "")
|
|
|
|
+ alert.informativeText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
|
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("Remove Security", comment: ""))
|
|
|
|
+ alert.beginSheetModal(for: NSWindow.currentWindow()) { returnCode in
|
|
|
|
+ if returnCode == .alertSecondButtonReturn {
|
|
|
|
+ DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.25) { [unowned self] in
|
|
|
|
+ KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
|
|
|
|
+ if success {
|
|
|
|
+ self.document?.unlock(withPassword: resultPassword)
|
|
|
|
+ self.clickChildTool(type: .secure, index: 2)
|
|
|
|
+ // /// 删除安全性设置
|
|
|
|
+ // if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
|
|
|
|
+ // self.isSaveKeyChain = false
|
|
|
|
+ // self.listView.document.unlock(withPassword: password)
|
|
|
|
+ // self.hiddenSecureLimitTip()
|
|
|
|
+ // self.recordRemoveSecureFlag()
|
|
|
|
+ // self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
+ //
|
|
|
|
+ // let tip = KMRemovePasswordResultTipView()
|
|
|
|
+ // tip.result = .success
|
|
|
|
+ // tip.showInView(superView: (self.listView.superview)!)
|
|
|
|
+ // } else {
|
|
|
|
+ // self.recordRemoveSecureFlag()
|
|
|
|
+ // self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
+ // let tip = KMRemovePasswordResultTipView()
|
|
|
|
+ // tip.result = .success
|
|
|
|
+ // self.hiddenSecureLimitTip()
|
|
|
|
+ //
|
|
|
|
+ // tip.showInView(superView: self.listView.superview!)
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ let controller = KMRemovePasswordWindowController(windowNibName: "KMRemovePasswordWindowController")
|
|
|
|
+ controller.pdfDocument = self.document
|
|
|
|
+ self.currentWindowController = controller
|
|
|
|
|
|
- self.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
|
|
|
|
|
|
+ controller.batchAction = { [unowned self] controller, files in
|
|
|
|
+ self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
+ self.currentWindowController = nil
|
|
|
|
+
|
|
|
|
+ self.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
|
|
|
|
+
|
|
|
|
+ let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
|
+ batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
|
+ let batchOperateFile = KMBatchOperateFile(filePath: files.first?.filePath ?? "")
|
|
|
|
+ batchWindowController.switchToOperateType(.RemovePassword, files: [batchOperateFile])
|
|
|
|
+ batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
|
+ }
|
|
|
|
|
|
- let batchWindowController = KMBatchOperateWindowController.sharedWindowController
|
|
|
|
- batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
|
- let batchOperateFile = KMBatchOperateFile(filePath: files.first?.filePath ?? "")
|
|
|
|
- batchWindowController.switchToOperateType(.RemovePassword, files: [batchOperateFile])
|
|
|
|
- batchWindowController.window?.makeKeyAndOrderFront("")
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- controller.cancelAction = { [unowned self] controller in
|
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
- self.currentWindowController = nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- controller.doneAction = { [unowned self] controller in
|
|
|
|
- self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
- self.currentWindowController = nil
|
|
|
|
|
|
+ controller.cancelAction = { [unowned self] controller in
|
|
|
|
+ self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
+ self.currentWindowController = nil
|
|
|
|
+ }
|
|
|
|
|
|
- KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
|
|
|
|
- if success {
|
|
|
|
- /// 删除安全性设置
|
|
|
|
- if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
|
|
|
|
- self.isSaveKeyChain = false
|
|
|
|
- self.listView.document.unlock(withPassword: password)
|
|
|
|
- self.hiddenSecureLimitTip()
|
|
|
|
- self.recordRemoveSecureFlag()
|
|
|
|
- self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
-
|
|
|
|
- let tip = KMRemovePasswordResultTipView()
|
|
|
|
- tip.result = .success
|
|
|
|
- tip.showInView(superView: (self.listView.superview)!)
|
|
|
|
- } else {
|
|
|
|
- self.recordRemoveSecureFlag()
|
|
|
|
- self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
- let tip = KMRemovePasswordResultTipView()
|
|
|
|
- tip.result = .success
|
|
|
|
- self.hiddenSecureLimitTip()
|
|
|
|
-
|
|
|
|
- tip.showInView(superView: self.listView.superview!)
|
|
|
|
|
|
+ controller.doneAction = { [unowned self] controller in
|
|
|
|
+ self.view.window?.endSheet((self.currentWindowController.window)!)
|
|
|
|
+ self.currentWindowController = nil
|
|
|
|
+
|
|
|
|
+ KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
|
|
|
|
+ if success {
|
|
|
|
+ /// 删除安全性设置
|
|
|
|
+ if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
|
|
|
|
+ self.isSaveKeyChain = false
|
|
|
|
+ self.listView.document.unlock(withPassword: password)
|
|
|
|
+ self.hiddenSecureLimitTip()
|
|
|
|
+ self.recordRemoveSecureFlag()
|
|
|
|
+ self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
+
|
|
|
|
+ let tip = KMRemovePasswordResultTipView()
|
|
|
|
+ tip.result = .success
|
|
|
|
+ tip.showInView(superView: (self.listView.superview)!)
|
|
|
|
+ } else {
|
|
|
|
+ self.recordRemoveSecureFlag()
|
|
|
|
+ self.recordSaveWatermarkFlag(type: .removePassword)
|
|
|
|
+ let tip = KMRemovePasswordResultTipView()
|
|
|
|
+ tip.result = .success
|
|
|
|
+ self.hiddenSecureLimitTip()
|
|
|
|
+
|
|
|
|
+ tip.showInView(superView: self.listView.superview!)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ await NSWindow.currentWindow().beginSheet(controller.window!)
|
|
}
|
|
}
|
|
- await NSWindow.currentWindow().beginSheet(controller.window!)
|
|
|
|
return
|
|
return
|
|
}
|
|
}
|
|
} else if type == .comparison {
|
|
} else if type == .comparison {
|