|
@@ -1144,18 +1144,27 @@ let LOCKED_KEY = "locked"
|
|
|
}
|
|
|
|
|
|
tip.passwordAction = { [unowned self] view in
|
|
|
- if (self.listView.document.allowsPrinting == false || self.listView.document.allowsCopying == false) {
|
|
|
- KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [weak self] result, password in
|
|
|
- if result == .cancel { /// 关闭
|
|
|
- return
|
|
|
- }
|
|
|
- /// 解密成功
|
|
|
- self?.hiddenSecureLimitTip()
|
|
|
- self?.isSaveKeyChain = false
|
|
|
- self?.listView.document.unlock(withPassword: password)
|
|
|
- }
|
|
|
+ self.removeOwnerPassword()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ func removeOwnerPassword() {
|
|
|
+ guard let doc = self.listView?.document else {
|
|
|
+ NSSound.beep()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if doc.allowsCopying && doc.allowsPrinting {
|
|
|
+ NSSound.beep()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: doc.documentURL) { [weak self] result, password in
|
|
|
+ if result == .cancel { /// 关闭
|
|
|
return
|
|
|
}
|
|
|
+ /// 解密成功
|
|
|
+ self?.hiddenSecureLimitTip()
|
|
|
+ self?.isSaveKeyChain = false
|
|
|
+ self?.listView.document.unlock(withPassword: password)
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2710,15 +2719,7 @@ let LOCKED_KEY = "locked"
|
|
|
|
|
|
func pdfListViewHaveDocumentAttribute() -> Bool {
|
|
|
if(!self.listView.document.allowsCopying) {
|
|
|
- KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [weak self] result, password in
|
|
|
- if (result == .cancel) {
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- self?.isSaveKeyChain = false
|
|
|
- self?.listView.document.unlock(withPassword: password)
|
|
|
- self?.hiddenSecureLimitTip()
|
|
|
- }
|
|
|
+ self.removeOwnerPassword()
|
|
|
return false
|
|
|
}
|
|
|
return true
|