Преглед изворни кода

【密码】- 使用权限密码还是开启密码,打开文档

liujiajie пре 11 месеци
родитељ
комит
2760fbd41f
20 измењених фајлова са 36 додато и 33 уклоњено
  1. 1 1
      PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift
  2. 1 1
      PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift
  3. 2 2
      PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift
  4. 1 1
      PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift
  5. 1 1
      PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift
  6. 1 1
      PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.swift
  7. 2 2
      PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift
  8. 2 2
      PDF Office/PDF Master/Class/PDFTools/Insert/KMPDFInsertWindowController.swift
  9. 1 1
      PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift
  10. 1 1
      PDF Office/PDF Master/Class/PDFTools/OCRNew/Controller/KMOCRPDFWindowController.swift
  11. 2 2
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditInsertPageWindow.swift
  12. 1 1
      PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/SplitWindowController.swift
  13. 8 9
      PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift
  14. 2 2
      PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.xib
  15. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift
  16. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift
  17. 1 1
      PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift
  18. 2 2
      PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift
  19. 2 0
      PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings
  20. 2 0
      PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/KMBatchOperateLeftViewController.swift

@@ -281,7 +281,7 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
         
         if lockFilePathArr!.count > lockFileIndex {
             let filePath = lockFilePathArr![lockFileIndex] as! String
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: filePath)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: filePath), type: .owner) { [unowned self] success, resultPassword in
                 self.closePwd()
                 if !resultPassword.isEmpty {
                     let file = KMBatchOperateFile(filePath: filePath, type: self.type!)

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMBatchOperateImageToPDFViewController.swift

@@ -504,7 +504,7 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
                 }
                 
                 if document.isLocked {
-                    KMBaseWindowController.checkPassword(url: url) { [unowned self] success, resultPassword in
+                    KMBaseWindowController.checkPassword(url: url, type: .owner) { [unowned self] success, resultPassword in
                         if success {
                             self.password = password
                             self.appendTextField.stringValue = url.path

+ 2 - 2
PDF Office/PDF Master/Class/Common/Base/KMBaseWindowController.swift

@@ -63,7 +63,7 @@ extension KMBaseWindowController {
 }
 
 extension KMBaseWindowController {
-    static func checkPassword(url: URL, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
+    static func checkPassword(url: URL, type: KMPasswordInputWindowType, password: String = "", completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
         // 判断路径 + document
         guard let document = CPDFDocument.init(url: url) else {
             return completion(false, "")
@@ -92,7 +92,7 @@ extension KMBaseWindowController {
         
         // 弹密码弹窗
         Task { @MainActor in
-            KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), url: url) { result , password in
+            KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), type: type, url: url) { result , password in
                 if (result == .cancel) {
                     completion(false, "")
                     return

+ 1 - 1
PDF Office/PDF Master/Class/Home/ViewController/KMHomeViewController+Action.swift

@@ -1283,7 +1283,7 @@ extension KMHomeViewController {
                 return
             }
             
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: openPanel.url!.path)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: openPanel.url!.path), type: .owner) { [unowned self] success, resultPassword in
                 if success {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.25) {
                         let controller = KMCompareWindowController(windowNibName: "KMCompareWindowController")

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Compare/View/KMCompareView.swift

@@ -495,7 +495,7 @@ extension KMCompareView {
                 completion(nil)
                 return
             } else {
-                KMBaseWindowController.checkPassword(url: NSURL(fileURLWithPath: filePath) as URL) { success, resultPassword in
+                KMBaseWindowController.checkPassword(url: NSURL(fileURLWithPath: filePath) as URL, type: .owner) { success, resultPassword in
                     if success {
                         let file = KMFileAttribute()
                         file.pdfDocument = pdfDocument

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Compress/Controller/KMCompressWIndowControllerNew.swift

@@ -23,7 +23,7 @@ class KMCompressWIndowControllerNew: KMBaseWindowController {
             if self.password.count != 0 {
                 self.compressView.documentURL = self.documentURL
             } else {
-                KMBaseWindowController.checkPassword(url: documentURL) { [unowned self] success, paasswordString in
+                KMBaseWindowController.checkPassword(url: documentURL, type: .owner) { [unowned self] success, paasswordString in
                     if success {
                         self.password = paasswordString
                         self.compressView.documentURL = self.documentURL

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMConvertWindowController.swift

@@ -115,7 +115,7 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
         if (isLoc) {
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
                 let url = self.pdfDocument?.documentURL
-                KMBaseWindowController.checkPassword(url: url!) { [unowned self] success, resultPassword in
+                KMBaseWindowController.checkPassword(url: url!, type: .owner) { [unowned self] success, resultPassword in
                     if success {
                         self.lockPassword = resultPassword
                         self.pdfDocument?.unlock(withPassword: resultPassword)
@@ -141,7 +141,7 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
             self.showWaitting()
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
                 let url = URL(fileURLWithPath: self.pdfDocument!.documentURL.path)
-                KMBaseWindowController.checkPassword(url: url) { result, password in
+                KMBaseWindowController.checkPassword(url: url, type: .owner) { result, password in
                     self.hideWaitting()
                     if password.count > 0 {
                         let unlockSuccess: Bool = ((self.pdfDocument?.unlock(withPassword: password)) != nil)

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Insert/KMPDFInsertWindowController.swift

@@ -135,7 +135,7 @@ class KMPDFInsertWindowController: KMBaseWindowController {
         self.locationRangePopUpButton.isEnabled = false
         
         if let data = self._pdfDocument?.isLocked, data {
-            Self.checkPassword(url: self._pdfDocument!.documentURL) { [weak self] success, resultPassword in
+            Self.checkPassword(url: self._pdfDocument!.documentURL, type: .owner) { [weak self] success, resultPassword in
                 if success {
                     self?._pdfDocument?.unlock(withPassword: resultPassword)
                     self?._password = resultPassword
@@ -361,7 +361,7 @@ class KMPDFInsertWindowController: KMBaseWindowController {
                     }
                     
                     if (pdfDoc.isLocked) {
-                        Self.checkPassword(url: fileURL) { [weak self] success, resultPassword in
+                        Self.checkPassword(url: fileURL, type: .owner) { [weak self] success, resultPassword in
                             if success {
                                 self?._fromFilePassword = resultPassword
                                 self?._fromFilePath = fileURL

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Merge/MergeNew/View/KMMergeView.swift

@@ -385,7 +385,7 @@ extension KMMergeView {
     func openPasswordFile(completion: @escaping ((_ success: Bool, _ resultPassword: String) -> Void)) {
         if lockFiles.count != 0 {
             let file = lockFiles[lockFilesIndex]
-            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: file.filePath)) { [unowned self] success, resultPassword in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: file.filePath), type: .owner) { [unowned self] success, resultPassword in
                 if success {
                     file.password = resultPassword
                     lockFilesIndex = lockFilesIndex + 1

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/OCRNew/Controller/KMOCRPDFWindowController.swift

@@ -212,7 +212,7 @@ class KMOCRPDFWindowController: NSWindowController, NSWindowDelegate, KMGOCRMana
         if !(self.pdfDocument?.isLocked ?? false) && ((self.pdfDocument?.unlock(withPassword: self.password)) != nil) {
             
         } else {
-            KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL) { success, pwd in
+            KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL, type: .owner) { success, pwd in
                 if success {
                     self.pdfDocument?.unlock(withPassword: pwd)
                     self.password = pwd

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditInsertPageWindow.swift

@@ -140,7 +140,7 @@ class KMPDFEditInsertPageWindow: NSWindowController {
         
         if let data = self.pdfDocument?.isLocked, data {
             DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL) { success, resultPassword in
+                KMBaseWindowController.checkPassword(url: self.pdfDocument!.documentURL, type: .owner) { success, resultPassword in
                     if (resultPassword.isEmpty == false) {
                         self.pdfDocument?.unlock(withPassword: resultPassword)
                         self._password = resultPassword
@@ -325,7 +325,7 @@ class KMPDFEditInsertPageWindow: NSWindowController {
                     let pdfDoc = CPDFDocument(url: fileURL)
                     if let data = pdfDoc?.isLocked, data {
                         DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
-                            KMBaseWindowController.checkPassword(url: fileURL) { result, pwd in
+                            KMBaseWindowController.checkPassword(url: fileURL, type: .owner) { result, pwd in
                                 if (pwd.isEmpty == false) {
                                     self._password = pwd
                                     self.fromFilePath = fileURL

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/SplitWindowController.swift

@@ -425,7 +425,7 @@ extension SplitWindowController {
     private func _setInputRange() {
         if let data = self._PDFDocument?.isLocked, data {
             if let url = self._fileURL {
-                Self.checkPassword(url: url) { [weak self] success, pwd in
+                Self.checkPassword(url: url, type: .owner) { [weak self] success, pwd in
                     if success {
                         self?.password = pwd
                         self?._PDFDocument?.unlock(withPassword: pwd)

+ 8 - 9
PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.swift

@@ -85,15 +85,11 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 
                 let ps = NSMutableParagraphStyle()
                 ps.lineSpacing = 5
-//                ps.lineBreakMode = .byTruncatingTail
-//                if (newValue == .open) {
-//                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter a Document Open Password.", comment: ""))"
-//                    despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegularFont(14), .paragraphStyle : ps])
-//                } else {
-                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("is protected, please enter the password to unlock it.", comment: ""))"
+
+                    despLabel!.stringValue = "\"\(fileName)\"\(NSLocalizedString("This PDF is password protected. Please enter the password below to access this PDF.", comment: ""))"
                     despLabel!.attributedStringValue = NSAttributedString(string: despLabel!.stringValue, attributes: [.foregroundColor : NSColor.titleColor(), .font : NSFont.SFProTextRegularFont(14), .paragraphStyle : ps])
-//                }
             }
+            
         }
     }
     
@@ -121,7 +117,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
         }
         
         if despLabel != nil {
-            despLabel.stringValue = NSLocalizedString("is protected, please enter the password to unlock it.", comment: "")
+            despLabel.stringValue = NSLocalizedString("This PDF is password protected. Please enter the password below to access this PDF.", comment: "")
             self.despLabel.textColor = NSColor.titleColor()
             despLabel.font = NSFont.SFProTextRegularFont(14)
             despLabel.isSelectable = false
@@ -191,7 +187,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
         }
         
         if passwordErrorLabel != nil {
-            passwordErrorLabel.stringValue = NSLocalizedString("Password error", comment: "")
+            passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
             passwordErrorLabel.font = NSFont.systemFont(ofSize: 12)
             passwordErrorLabel.wantsLayer = true
             passwordErrorLabel.textColor = NSColor.km_init(hex: "#F3465B")
@@ -304,6 +300,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor
@@ -329,6 +326,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor
@@ -348,6 +346,7 @@ private var passwordInputWindow_private: KMPasswordInputWindow?
                 } else { /// 密码错误
                     if passwordErrorLabel != nil {
                         passwordErrorLabel.isHidden = false
+                        passwordErrorLabel.stringValue = NSLocalizedString("Incorrect password. Please try again.", comment: "")
                     }
                     if secureTextFiled != nil {
                         secureTextFiled.backgroundView.layer?.borderColor = NSColor.km_init(hex: "#F3465B").cgColor

+ 2 - 2
PDF Office/PDF Master/Class/PDFTools/Secure/Window/KMPasswordInputWindow.xib

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
     <dependencies>
         <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22505"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Thumbnail.swift

@@ -450,7 +450,7 @@ extension KMLeftSideViewController {
                 let pdfDoc = CPDFDocument(url: fileURL)
                 if let data = pdfDoc?.isLocked, data {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                        KMBaseWindowController.checkPassword(url: fileURL) { [unowned self] success, resultPassword in
+                        KMBaseWindowController.checkPassword(url: fileURL, type: .owner) { [unowned self] success, resultPassword in
                             self.km_quick_endSheet()
                             if (resultPassword.isEmpty == false) {
                                 

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController.swift

@@ -1393,7 +1393,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                             var insertIndexSet = IndexSet()
                             var pdf = CPDFDocument(url: URL(fileURLWithPath: path))
                             if let data = pdf?.isEncrypted, data {
-                                KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path)) { success, resultPassword in
+                                KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: path), type: .owner) { success, resultPassword in
                                     if success && resultPassword.isEmpty == false {
                                         for i in 0 ..< (pdf?.pageCount ?? 0) {
                                             let page = pdf?.page(at: i).copy() as? CPDFPage
@@ -1482,7 +1482,7 @@ extension KMLeftSideViewController: NSTableViewDelegate, NSTableViewDataSource {
                     let pdf = CPDFDocument(url: url!)
                     if let data = pdf?.isEncrypted, data {
 //                        KMDecryptWindowController *vc = [[KMDecryptWindowController alloc] init];
-                        KMBaseWindowController.checkPassword(url: url!) { success, resultPassword in
+                        KMBaseWindowController.checkPassword(url: url!, type: .owner) { success, resultPassword in
                             if success && resultPassword.isEmpty == false {
                                 pdf?.unlock(withPassword: resultPassword)
                                 for i in 0 ..< (pdf?.pageCount ?? 0) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -1013,7 +1013,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     if filePath.pathExtension.lowercased() == "pdf" {
                         if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
                             if #available(macOS 13.0, *) {
-                                KMBaseWindowController.checkPassword(url: URL(filePath: filePath)) { [unowned self] success, resultPassword in
+                                KMBaseWindowController.checkPassword(url: URL(filePath: filePath), type: .owner) { [unowned self] success, resultPassword in
                                     self!.addImageStamp(withSecurityPDFFilePath: filePath, password: resultPassword, removeBGColor: (accessoryCtr.selectedButton.state == .on))
                                 }
                             } else {

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

@@ -4271,7 +4271,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                         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
+                                    KMBaseWindowController.checkPassword(url: self.document!.documentURL!, type: .owner) { [unowned self] success, resultPassword in
                                         if success {
                                             self.document?.unlock(withPassword: resultPassword)
                                             self.clickChildTool(type: .secure, index: 2)
@@ -4318,7 +4318,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                             self.view.window?.endSheet((self.currentWindowController.window)!)
                             self.currentWindowController = nil
                             
-                            KMBaseWindowController.checkPassword(url: self.document!.documentURL!) { [unowned self] success, resultPassword in
+                            KMBaseWindowController.checkPassword(url: self.document!.documentURL!, type: .owner) { [unowned self] success, resultPassword in
                                 if success {
                                     /// 删除安全性设置
                                     if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {

+ 2 - 0
PDF Office/PDF Master/Strings/zh-Hans.lproj/Localizable.strings

@@ -1309,6 +1309,8 @@
 
 "This PDF is password protected. Please enter the password below to access this PDF." = "该文档受密码保护。请在下面输入密码开启文档。";
 
+"Permission Password" = "权限密码";
+
 "Share" = "分享";
 
 "Upgrade your PDF Reader Pro and enjoy all the benefits:" = "升级PDF Reader Pro,畅享进阶功能!";

+ 2 - 0
PDF Office/PDF Master/Strings/zh-Hant.lproj/Localizable.strings

@@ -1311,6 +1311,8 @@
 
 "This PDF is password protected. Please enter the password below to access this PDF." = "此文件受密碼保護,請輸入密碼方可開啟文件。";
 
+"Permission Password" = "許可權密碼";
+
 "Share" = "分享";
 
 "Upgrade your PDF Reader Pro and enjoy all the benefits:" = "升級PDF Reader Pro享受完整功能:";