Browse Source

【工具】密码弹窗统一

lizhe 1 year ago
parent
commit
877f3aca60

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

@@ -284,14 +284,11 @@ class KMBatchOperateLeftViewController: NSViewController,NSTableViewDelegate,NST
         
         if lockFilePathArr!.count > lockFileIndex {
             let filePath = lockFilePathArr![lockFileIndex] as! String
-            let com = PasswordWindowController(windowNibName: "PasswordWindowController")
-            com.fileURL = URL(fileURLWithPath: filePath)
-            self.km_beginSheet(windowC: com)
-            com.closeCallBack = { [unowned self] password in
+            KMBaseWindowController.checkPassword(url: URL(fileURLWithPath: filePath)) { [unowned self] success, resultPassword in
                 self.closePwd()
-                if !password.isEmpty {
+                if !resultPassword.isEmpty {
                     let file = KMBatchOperateFile(filePath: filePath, type: self.type!)
-                    file.password = password
+                    file.password = resultPassword
                     self.files.append(file)
                     self.tableView.reloadData()
                 }

+ 0 - 102
PDF Office/PDF Master/Class/Batch/WindowController/PasswordWindowController.swift

@@ -1,102 +0,0 @@
-//
-//  PasswordWindowController.swift
-//  PDF Reader Pro
-//
-//  Created by kdanmobile on 2023/11/2.
-//
-
-import Cocoa
-
-typealias closePwdCallBack = (_ password: String) -> ()
-
-@objc protocol PasswordWindowDelegate: AnyObject {
-    @objc optional func didFinshedUnlockFile(_ passwordWindowCtr: PasswordWindowController, password: String)
-    @objc optional func didCancelUnlockFile(_ passwordWindowCtr: PasswordWindowController)
-}
-
-@objc class PasswordWindowController: NSWindowController{
-    var fileURL: URL?
-    var delegate: PasswordWindowDelegate?
-    var tag: Int = 0
-    var password: String?
-    var closeCallBack: closePwdCallBack?
-    
-    @IBOutlet var passwordTextField: NSSecureTextField!
-    @IBOutlet var titleTextField: NSTextField!
-    @IBOutlet var textField: NSTextField!
-    @IBOutlet var openButton: NSButton!
-    @IBOutlet var cancelButton: NSButton!
-    
-    override init(window: NSWindow?) {
-        super.init(window: window)
-    }
-    
-    required init?(coder: NSCoder) {
-        super.init(coder: coder)
-    }
-    
-    override func windowDidLoad() {
-        super.windowDidLoad()
-        
-        self.titleTextField.stringValue = fileURL?.lastPathComponent ?? ""
-        self.textField.stringValue = NSLocalizedString("This PDF is password protected. Please enter the password below to access this PDF.", comment: "")
-        self.openButton.title = NSLocalizedString("Open", comment: "")
-        self.cancelButton.title = NSLocalizedString("Cancel", comment: "")
-    }
-    
-    @IBAction func cancelAction(_ sender: NSButton) {
-        self.close()
-    }
-    
-    @IBAction func OKAction(_ sender: NSButton) {
-        guard let pdfDoc = CPDFDocument(url: self.fileURL) else {
-            __NSBeep()
-            return
-        }
-        
-        let isOk = pdfDoc.unlock(withPassword: self.passwordTextField.stringValue)
-        if isOk {
-            if pdfDoc.permissionsStatus == .owner {
-                self.password = self.passwordTextField.stringValue
-                self.close()
-            } else{
-                self.incorrectPasswordAlert()
-            }
-        } else {
-            self.incorrectPasswordAlert()
-        }
-    }
-    
-    func incorrectPasswordAlert() {
-        let alert = NSAlert()
-        alert.alertStyle = .critical
-        alert.messageText = NSLocalizedString("Incorrect password. Please check your password and try again.", comment: "")
-        alert.runModal()
-    }
-    
-    @objc func didEndSheet(_ sheet: NSWindow, returnCode: NSInteger, contextInfo: UnsafeMutableRawPointer?) {
-        if contextInfo != nil {
-            let handler = contextInfo!.assumingMemoryBound(to: ((String) -> Void).self).pointee
-            handler(password ?? "")
-        }
-    }
-
-    func beginSheetModal(for window: NSWindow, completionHandler handler: ((String) -> Void)?) {
-        struct Context {
-            var handler: ((String) -> Void)?
-        }
-        
-        var context = Context(handler: handler)
-        
-        // Pass the address of the struct as contextInfo
-        let contextPointer = UnsafeMutableRawPointer(&context)
-        NSApp.beginSheet(self.window!, modalFor: window, modalDelegate: self, didEnd: #selector(didEndSheet(_:returnCode:contextInfo:)), contextInfo: contextPointer)
-    }
-
-    
-    override func close() {
-        if (self.closeCallBack != nil) {
-            closeCallBack!(password ?? "")
-        }
-    }
-}

+ 0 - 142
PDF Office/PDF Master/Class/Batch/WindowController/PasswordWindowController.xib

@@ -1,142 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
-    <dependencies>
-        <deployment identifier="macosx"/>
-        <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
-        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
-    </dependencies>
-    <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="PasswordWindowController" customModule="PDF_Master" customModuleProvider="target">
-            <connections>
-                <outlet property="_cancelButton" destination="10" id="2Rq-Y5-VcA"/>
-                <outlet property="_openButton" destination="9" id="AOP-hG-el8"/>
-                <outlet property="_passwordTextField" destination="7" id="42"/>
-                <outlet property="_textField" destination="8" id="Pcr-bw-2m1"/>
-                <outlet property="_titleTextField" destination="45" id="55"/>
-                <outlet property="cancelButton" destination="10" id="LnY-wb-9IH"/>
-                <outlet property="openButton" destination="9" id="ry0-hN-OF4"/>
-                <outlet property="passwordTextField" destination="7" id="kMA-iN-LOA"/>
-                <outlet property="textField" destination="8" id="rvG-TA-6Xf"/>
-                <outlet property="titleTextField" destination="45" id="sbf-Cc-xq2"/>
-                <outlet property="window" destination="5" id="40"/>
-            </connections>
-        </customObject>
-        <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
-        <customObject id="-3" userLabel="Application" customClass="NSObject"/>
-        <window title="PDFName.pdf" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5">
-            <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" utility="YES"/>
-            <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
-            <rect key="contentRect" x="120" y="65" width="381" height="205"/>
-            <rect key="screenRect" x="0.0" y="0.0" width="1440" height="875"/>
-            <view key="contentView" id="6">
-                <rect key="frame" x="0.0" y="0.0" width="381" height="205"/>
-                <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                <subviews>
-                    <imageView translatesAutoresizingMaskIntoConstraints="NO" id="12">
-                        <rect key="frame" x="15" y="104" width="60" height="60"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="60" id="AAa-Cu-TRE"/>
-                            <constraint firstAttribute="width" constant="60" id="T2H-T0-PF2"/>
-                        </constraints>
-                        <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyUpOrDown" image="KMImageNameLockIcon" id="13"/>
-                    </imageView>
-                    <box verticalHuggingPriority="750" boxType="separator" translatesAutoresizingMaskIntoConstraints="NO" id="11">
-                        <rect key="frame" x="0.0" y="49" width="381" height="5"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="1" id="ZZq-vF-nGi"/>
-                        </constraints>
-                    </box>
-                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="10">
-                        <rect key="frame" x="206" y="7" width="76" height="32"/>
-                        <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="14">
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                            <font key="font" metaFont="system"/>
-                            <string key="keyEquivalent" base64-UTF8="YES">
-Gw
-</string>
-                        </buttonCell>
-                        <connections>
-                            <action selector="cancelAction:" target="-2" id="ezk-NS-fla"/>
-                        </connections>
-                    </button>
-                    <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="9">
-                        <rect key="frame" x="300" y="7" width="67" height="32"/>
-                        <constraints>
-                            <constraint firstAttribute="height" constant="20" id="Xf5-5t-kUy"/>
-                        </constraints>
-                        <buttonCell key="cell" type="push" title="Open" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="15">
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
-                            <font key="font" metaFont="system"/>
-                            <string key="keyEquivalent" base64-UTF8="YES">
-DQ
-</string>
-                        </buttonCell>
-                        <connections>
-                            <action selector="OKAction:" target="-2" id="ZAZ-9I-KPf"/>
-                        </connections>
-                    </button>
-                    <secureTextField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="7">
-                        <rect key="frame" x="124" y="80" width="199" height="22"/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="199" id="9Gd-ba-hvr"/>
-                            <constraint firstAttribute="height" constant="22" id="s2x-gL-cQh"/>
-                        </constraints>
-                        <secureTextFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" usesSingleLineMode="YES" id="17">
-                            <font key="font" metaFont="system"/>
-                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                            <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
-                            <allowedInputSourceLocales>
-                                <string>NSAllRomanInputSourcesLocaleIdentifier</string>
-                            </allowedInputSourceLocales>
-                        </secureTextFieldCell>
-                    </secureTextField>
-                    <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="45">
-                        <rect key="frame" x="89" y="161" width="278" height="16"/>
-                        <textFieldCell key="cell" lineBreakMode="charWrapping" sendsActionOnEndEditing="YES" alignment="center" title="Label" id="46">
-                            <font key="font" metaFont="system"/>
-                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                        </textFieldCell>
-                    </textField>
-                    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="8">
-                        <rect key="frame" x="89" y="112" width="278" height="48"/>
-                        <constraints>
-                            <constraint firstAttribute="width" constant="274" id="tBH-cN-Iys"/>
-                        </constraints>
-                        <textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="This PDF is password protected. Please enter the password below to access this PDF." id="16">
-                            <font key="font" metaFont="system"/>
-                            <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
-                            <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
-                        </textFieldCell>
-                    </textField>
-                </subviews>
-                <constraints>
-                    <constraint firstItem="7" firstAttribute="top" secondItem="8" secondAttribute="bottom" constant="10" id="3nh-uS-Rgh"/>
-                    <constraint firstAttribute="bottom" secondItem="9" secondAttribute="bottom" constant="14" id="72E-00-nm8"/>
-                    <constraint firstItem="8" firstAttribute="trailing" secondItem="45" secondAttribute="trailing" id="DyV-Sk-dE2"/>
-                    <constraint firstItem="11" firstAttribute="leading" secondItem="6" secondAttribute="leading" id="E3K-1g-G6j"/>
-                    <constraint firstAttribute="trailing" secondItem="7" secondAttribute="trailing" constant="58" id="Jsx-Rh-DcP"/>
-                    <constraint firstItem="9" firstAttribute="top" secondItem="11" secondAttribute="bottom" constant="17" id="LGy-uv-Bgy"/>
-                    <constraint firstItem="8" firstAttribute="top" secondItem="45" secondAttribute="bottom" constant="1" id="M3A-Xs-tuP"/>
-                    <constraint firstAttribute="trailing" secondItem="9" secondAttribute="trailing" constant="21" id="NIT-Rl-zmd"/>
-                    <constraint firstAttribute="trailing" secondItem="11" secondAttribute="trailing" id="Ous-re-PEa"/>
-                    <constraint firstItem="12" firstAttribute="leading" secondItem="6" secondAttribute="leading" constant="15" id="Sy2-Pg-ved"/>
-                    <constraint firstItem="8" firstAttribute="leading" secondItem="12" secondAttribute="trailing" constant="16" id="dJj-F8-trs"/>
-                    <constraint firstAttribute="trailing" secondItem="8" secondAttribute="trailing" constant="16" id="iEo-Tw-TaD"/>
-                    <constraint firstItem="8" firstAttribute="leading" secondItem="45" secondAttribute="leading" id="iuR-Tv-XBg"/>
-                    <constraint firstItem="9" firstAttribute="centerY" secondItem="10" secondAttribute="centerY" id="ngn-xn-qC0"/>
-                    <constraint firstItem="12" firstAttribute="top" secondItem="6" secondAttribute="top" constant="41" id="obN-ML-8f7"/>
-                    <constraint firstItem="9" firstAttribute="leading" secondItem="10" secondAttribute="trailing" constant="32" id="qAm-Sy-wpl"/>
-                    <constraint firstItem="11" firstAttribute="top" secondItem="7" secondAttribute="bottom" constant="28" id="vEd-JE-D9G"/>
-                </constraints>
-            </view>
-            <connections>
-                <outlet property="delegate" destination="-2" id="41"/>
-            </connections>
-            <point key="canvasLocation" x="156.5" y="220.5"/>
-        </window>
-    </objects>
-    <resources>
-        <image name="KMImageNameLockIcon" width="40" height="44"/>
-    </resources>
-</document>

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

@@ -496,10 +496,8 @@ class KMBatchOperateImageToPDFViewController: KMBatchOperateBaseViewController,
                 }
                 
                 if document.isLocked {
-                    let com = PasswordWindowController(windowNibName: "PasswordWindowController")
-                    com.fileURL = url
-                    com.beginSheetModal(for: self.view.window!) { (password) in
-                        if password.count > 0 {
+                    KMBaseWindowController.checkPassword(url: url) { [unowned self] success, resultPassword in
+                        if success {
                             self.password = password
                             self.appendTextField.stringValue = url.path
                         }

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

@@ -92,17 +92,12 @@ extension KMBaseWindowController {
         
         // 弹密码弹窗
         Task { @MainActor in
-            let passwordWindowController = PasswordWindowController(windowNibName: "PasswordWindowController")
-            passwordWindowController.fileURL = url
-            let window = NSWindow.currentWindow()
-            window.km_beginSheet(windowC: passwordWindowController)
-            passwordWindowController.closeCallBack = { passwordString in
-                window.km_quick_endSheet()
-                if passwordString.count != 0 {
-                    document.unlock(withPassword: passwordString)
-                    completion(true, passwordString)
-                } else {
+            KMPasswordInputWindow.openWindow(window: NSWindow.currentWindow(), url: url) { result , password in
+                if (result == .cancel) {
                     completion(false, "")
+                    return
+                } else {
+                    completion(true, password ?? "")
                 }
             }
         }

+ 0 - 61
PDF Office/PDF Master/Class/PDFTools/Compare/KMCompareWindowController.swift

@@ -110,76 +110,15 @@ class KMCompareWindowController: KMBaseWindowController {
         let filePath = config.fileOldAttribute.pdfDocument?.documentURL.path
         let pdfDocument = CPDFDocument(url: URL(fileURLWithPath: filePath!))
 
-//        if pdfDocument!.isLocked && self.pdfOldDocument?.isLocked == true {
-//            DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
-//                let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
-//                passwordWC.fileURL = URL(fileURLWithPath: filePath)
-//                passwordWC.beginSheetModalForWindow(self.window) { password in
-//                    if let password = password {
-//                        pdfDocument.unlock(withPassword: password)
-//                        config.fileOldAttribute.pdfDocument = pdfDocument
-//                        config.fileOldAttribute.password = password
-//                        config.fileOldAttribute.bAllPage = true
-//                        config.fileOldAttribute.pagesType = PDFSeleectPageType_AllPages
-//                        self.pdfOldDocument = PDFDocument(url: URL(fileURLWithPath: filePath))
-//                        if self.pdfOldDocument?.isLocked == true {
-//                            self.pdfOldDocument?.unlock(withPassword: password)
-//                        }
-//                        self.oldPDFView.document = self.pdfOldDocument
-//                        self.oldPDFView.autoScales = true
-//                        self.oldPDFView.delegate = self
-//                        self.updateOldFileQKSelectedPathsWithPath(self.pdfOldDocument?.documentURL?.path ?? "")
-//                        self.reloadOldPDFData()
-//                    }
-//                }
-//            }
-//            return
-//        }
-
         let filePath1 = config.fileNewAttribute.pdfDocument?.documentURL.path
         let pdfDocument1 = CPDFDocument(url: URL(fileURLWithPath: filePath1!))
 
-//        if pdfDocument1.isLocked && self.pdfNewDocument?.isLocked == true {
-//            DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
-//                let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
-//                passwordWC.fileURL = URL(fileURLWithPath: filePath1)
-//                passwordWC.beginSheetModalForWindow(self.window) { password in
-//                    if let password = password {
-//                        pdfDocument.unlock(withPassword: password)
-//                        config.fileNewAttribute.pdfDocument = pdfDocument1
-//                        config.fileNewAttribute.password = password
-//                        config.fileNewAttribute.bAllPage = true
-//                        config.fileNewAttribute.pagesType = PDFSeleectPageType_AllPages
-//                        self.pdfNewDocument = PDFDocument(url: URL(fileURLWithPath: filePath1))
-//                        if self.pdfNewDocument?.isLocked == true {
-//                            self.pdfNewDocument?.unlock(withPassword: password)
-//                        }
-//                        self.pdfNewView.document = self.pdfNewDocument
-//                        self.pdfNewView.autoScales = true
-//                        self.pdfNewView.delegate = self
-//                        self.addFileContentView.isHidden = true
-//                        self.updateNewFileQKSelectedPathsWithPath(self.pdfNewDocument?.documentURL?.path ?? "")
-//                        self.reloadNewPDFData()
-//                    }
-//                }
-//            }
-//            return
-//        }
-
         DispatchQueue.global().async {
             let oldDoc = CPDFDocument(url: config.fileOldAttribute.pdfDocument?.documentURL)
             oldDoc!.unlock(withPassword: config.fileOldAttribute.password)
             let doc = CPDFDocument(url: config.fileNewAttribute.pdfDocument?.documentURL)
             doc!.unlock(withPassword: config.fileNewAttribute.password)
             
-//            if let compareLoadingWVC = self.compareLoadingWVC {
-//                compareLoadingWVC.maxPageCount = config.fileOldAttribute.pdfDocument.pageCount + config.fileNewAttribute.pdfDocument.pageCount
-//            }
-            
-//            if self._compareCancel {
-//                return
-//            }
-            
             if self.compareView.fileType == .coverting {
                 let pdfCompareOverlay = CPDFCompareOverlay(oldDocument: oldDoc, oldPageRange: config.fileOldAttribute.pagesString, newDocument: doc, newPageRange: config.fileNewAttribute.pagesString)
                 

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

@@ -114,13 +114,11 @@ let kConvertFileSavePath = (kTempSavePath?.stringByAppendingPathComponent("conve
         let isLoc: Bool = self.pdfDocument!.isLocked
         if (isLoc) {
             DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.5) {
-                let com = PasswordWindowController(windowNibName: "PasswordWindowController")
-                com.fileURL = self.pdfDocument?.documentURL
-                NSWindow.currentWindow().km_beginSheet(windowC: com)
-                com.closeCallBack = { password in
-                    if password.count > 0 {
-                        self.lockPassword = password
-                        self.pdfDocument?.unlock(withPassword: password)
+                let url = self.pdfDocument?.documentURL
+                KMBaseWindowController.checkPassword(url: url!) { [unowned self] success, resultPassword in
+                    if success {
+                        self.lockPassword = resultPassword
+                        self.pdfDocument?.unlock(withPassword: resultPassword)
                         self.currentPage = self.pdfDocument?.page(at: 0)
                         self.convertType = .Word
                     }

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

@@ -361,26 +361,6 @@ class KMPDFInsertWindowController: KMBaseWindowController {
                     }
                     
                     if (pdfDoc.isLocked) {
-//                        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-//                            PasswordWindowController *com = [[PasswordWindowController alloc] initWithWindowNibName:@"PasswordWindowController"];
-//                            com.fileURL = fileURL;
-//
-//                            [com beginSheetModalForWindow:self.window completionHandler:^(NSString *password) {
-//                                if (password) {
-//                                    self.password = password;
-//                                    self.fromFilePath = fileURL;
-//                                    _outputFolderText.stringValue = [_fromFilePath path];
-//
-//                                    [_pageRangeBox selectItemAtIndex:0];
-//                                    [self.window makeFirstResponder:self];
-//                                    [_pageRangeBox setEditable:NO];
-//                                    _pagesText.stringValue = [NSString stringWithFormat:@"%d",1];
-//                                    [_insertButton setEnabled:YES];
-//
-//                                }
-//                            }];
-//                            [com release];
-//                        });
                         Self.checkPassword(url: fileURL) { [weak self] success, resultPassword in
                             if success {
                                 self?._fromFilePassword = resultPassword

+ 0 - 1
PDF Office/PDF Master/Class/PDFTools/Merge/OCPart/KMPDFEditAppendWindow.m

@@ -187,7 +187,6 @@ static KMPDFEditAppendWindow *windowController = nil;
 @property (weak) IBOutlet NSTextField *limitLable;
 @property (weak) IBOutlet NSImageView *limitTipIv;
 
-@property (nonatomic, strong) PasswordWindowController *passwordWindowController;
 @property (nonatomic, strong) KMSavePanelAccessoryController *savePanelAccessoryViewController;
 
 @property (nonatomic, assign) BOOL canMerge;

+ 0 - 21
PDF Office/PDF Master/Class/PDFTools/PageEdit/Window/KMPDFEditExtractWindow.swift

@@ -68,27 +68,6 @@ class KMPDFEditExtractWindow: NSWindowController {
         self._extractPerPageFlag = false
         self.extractAsDocumentsPerPageButton.title = KMLocalizedString("Each page in a separate file", nil)
         
-//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-//            if ([self.pdfDocument isEncrypted] && [self.pdfDocument isLocked]) {
-//                PasswordWindowController *com = [[PasswordWindowController alloc] initWithWindowNibName:@"PasswordWindowController"];
-//                com.fileURL = [self.pdfDocument documentURL];
-//                [com beginSheetModalForWindow:self.window completionHandler:^(NSString *password) {
-//                    if (password) {
-//                        self.attribute.password = password;
-//                        [self.pdfDocument unlockWithPassword:password];
-//                    } else {
-//                        self.pdfDocument = nil;
-//                        [NSApp endSheet:[self window]];
-//                        [[self window] orderOut:self];
-//                        [self release];
-//                    }
-//
-//                }];
-//                [com release];
-//            }
-            
-//        });
-        
         self.window?.title =  KMLocalizedString("Extract",nil)
         self.cancelButton.title = KMLocalizedString("Cancel",nil)
         self.extractButton.title = KMLocalizedString("Extract",nil)

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

@@ -109,20 +109,7 @@ class KMPDFEditInsertBlankPageWindow: NSWindowController {
         
         if let data = self.pdfDocument?.isLocked, data {
             DispatchQueue.main.asyncAfter(deadline: .now()+0.5) {
-//                PasswordWindowController *passwordVC = [[PasswordWindowController alloc] initWithWindowNibName:@"PasswordWindowController"];
-//                passwordVC.fileURL = [self.pdfDocument documentURL];
-                
-//                [passwordVC beginSheetModalForWindow:self.window completionHandler:^(NSString *password) {
-//                    if (password) {
-//                        [_pdfDocument unlockWithPassword:password];
-//                        self.password = password;
-                        
-//                        _pageCountLabel.stringValue = [NSString stringWithFormat:@"/%ld",_pdfDocument.pageCount];
-//                        _byPageStepper.minValue = 1.0;
-//                        _byPageStepper.maxValue = _pdfDocument.pageCount;
-                        
-//                    }
-//                }
+
             }
         } else {
             self.byPageStepper.minValue = 1.0

+ 3 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/KMLeftSideViewController+Action.swift

@@ -1238,16 +1238,12 @@ extension KMLeftSideViewController {
                 let pdfDoc = CPDFDocument(url: fileURL)
                 if let data = pdfDoc?.isLocked, data {
                     DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
-                        let com = PasswordWindowController(windowNibName: "PasswordWindowController")
-                        com.fileURL = fileURL
-                        self.km_beginSheet(windowC: com)
-                        
-                        com.closeCallBack = { [unowned self] password in
+                        KMBaseWindowController.checkPassword(url: fileURL) { [unowned self] success, resultPassword in
                             self.km_quick_endSheet()
 //                        }
-                            if (password.isEmpty == false) {
+                            if (resultPassword.isEmpty == false) {
                                 
-                                let insertVC = KMPDFEditInsertPageWindow(document: document, path: fileURL, password: password)
+                                let insertVC = KMPDFEditInsertPageWindow(document: document, path: fileURL, password: resultPassword)
                                 insertVC.insertLocation = 3
                                 insertVC.currentPage = idx + 1
                                 self.km_beginSheet(windowC: insertVC)

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

@@ -1012,16 +1012,13 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
                     
                     if filePath.pathExtension.lowercased() == "pdf" {
                         if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
-                            let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
                             if #available(macOS 13.0, *) {
-                                passwordWC.fileURL = URL(filePath: filePath)
+                                KMBaseWindowController.checkPassword(url: URL(filePath: filePath)) { [unowned self] success, resultPassword in
+                                    self!.addImageStamp(withSecurityPDFFilePath: filePath, password: resultPassword, removeBGColor: (accessoryCtr.selectedButton.state == .on))
+                                }
                             } else {
-                                
+                                // Fallback on earlier versions
                             }
-                            passwordWC.beginSheetModal(for: myself.view.window!) { [weak self] password in
-                                self!.addImageStamp(withSecurityPDFFilePath: filePath, password: password, removeBGColor: (accessoryCtr.selectedButton.state == .on))
-                            }
-                            NSSound.beep()
                             return
                         }
                     }

+ 0 - 16
PDF Office/PDF Reader Pro.xcodeproj/project.pbxproj

@@ -4949,12 +4949,6 @@
 		BBFDFAA22AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
 		BBFDFAA32AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
 		BBFDFAA42AF3815C00E08AA2 /* KMTextHintWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */; };
-		BBFDFAA62AF3899400E08AA2 /* PasswordWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFDFAA52AF3899400E08AA2 /* PasswordWindowController.swift */; };
-		BBFDFAA72AF3899400E08AA2 /* PasswordWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFDFAA52AF3899400E08AA2 /* PasswordWindowController.swift */; };
-		BBFDFAA82AF3899400E08AA2 /* PasswordWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFDFAA52AF3899400E08AA2 /* PasswordWindowController.swift */; };
-		BBFDFAAA2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA92AF389B700E08AA2 /* PasswordWindowController.xib */; };
-		BBFDFAAB2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA92AF389B700E08AA2 /* PasswordWindowController.xib */; };
-		BBFDFAAC2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */ = {isa = PBXBuildFile; fileRef = BBFDFAA92AF389B700E08AA2 /* PasswordWindowController.xib */; };
 		BBFE6E582930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
 		BBFE6E592930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
 		BBFE6E5A2930724B00142C01 /* KMMergePageModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFE6E572930724B00142C01 /* KMMergePageModel.swift */; };
@@ -7170,8 +7164,6 @@
 		BBFDFA922AF328B200E08AA2 /* KMBatchOperateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMBatchOperateManager.swift; sourceTree = "<group>"; };
 		BBFDFA9D2AF3814000E08AA2 /* KMTextHintWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMTextHintWindowController.swift; sourceTree = "<group>"; };
 		BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = KMTextHintWindowController.xib; sourceTree = "<group>"; };
-		BBFDFAA52AF3899400E08AA2 /* PasswordWindowController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PasswordWindowController.swift; sourceTree = "<group>"; };
-		BBFDFAA92AF389B700E08AA2 /* PasswordWindowController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordWindowController.xib; sourceTree = "<group>"; };
 		BBFE6E572930724B00142C01 /* KMMergePageModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergePageModel.swift; sourceTree = "<group>"; };
 		BBFE6E5B2930809A00142C01 /* KMMergeCollectionPageViewItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMMergeCollectionPageViewItem.swift; sourceTree = "<group>"; };
 		BBFE6E5C2930809A00142C01 /* KMMergeCollectionPageViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMMergeCollectionPageViewItem.xib; sourceTree = "<group>"; };
@@ -12921,8 +12913,6 @@
 				BBC4F9ED2AEB58470098A1A8 /* KMAlertWindowController.xib */,
 				BBFDFA9D2AF3814000E08AA2 /* KMTextHintWindowController.swift */,
 				BBFDFAA12AF3815B00E08AA2 /* KMTextHintWindowController.xib */,
-				BBFDFAA52AF3899400E08AA2 /* PasswordWindowController.swift */,
-				BBFDFAA92AF389B700E08AA2 /* PasswordWindowController.xib */,
 			);
 			path = WindowController;
 			sourceTree = "<group>";
@@ -13784,7 +13774,6 @@
 				BBC348462956A638008D2CD1 /* KMEditBackgroundController.xib in Resources */,
 				BB8810882B4F7C2200AFA63E /* KMVerificationAlertViewController.xib in Resources */,
 				BBA2109429ACC10F00E6B346 /* signlist_add.pdf in Resources */,
-				BBFDFAAA2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */,
 				BB1969D12B2833FF00922736 /* KMProgressWindowController.xib in Resources */,
 				ADE86A7B2B0221E100414DFA /* KMSecurityWindowController.xib in Resources */,
 				BBC8A7752B0640C200FA9377 /* KMBotaSearchViewController.xib in Resources */,
@@ -14212,7 +14201,6 @@
 				BB65A0832AF8FEA1003A27A0 /* KMBatchOperateRemoveHeaderFooterViewController.xib in Resources */,
 				BB4F7E9A2B0C858D0077EC8C /* KMNoteTypeCollectionViewItem.xib in Resources */,
 				ADDF83842B391A5D00A81A4E /* DSignatureSaveTypeViewController.xib in Resources */,
-				BBFDFAAB2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */,
 				ADE86AA92B031FFA00414DFA /* KMCompareView.xib in Resources */,
 				9FF94F1D29A770B500B1EF69 /* KMFillSignShapePanel.xib in Resources */,
 				BBC348472956A638008D2CD1 /* KMEditBackgroundController.xib in Resources */,
@@ -14832,7 +14820,6 @@
 				BBA9223D2B4E97540061057A /* KMPurchaseLimitWindowController.xib in Resources */,
 				BB276A5E2B038D3A00AB5578 /* KMOCRPDFWindowController.xib in Resources */,
 				AD0FA50029A8DD8700EDEB50 /* KMRegisterSuccessView.xib in Resources */,
-				BBFDFAAC2AF389B700E08AA2 /* PasswordWindowController.xib in Resources */,
 				894A00F72976314C0070ED83 /* KMPDFViewPanelSetViewController.xib in Resources */,
 				899700FB28F4051B009AF911 /* KMAnnotationViewController.xib in Resources */,
 				BB3EAEB2293E3D6000D92407 /* KMConvertBaseWindowController.xib in Resources */,
@@ -15735,7 +15722,6 @@
 				9F1FE4ED29406E4700E952CA /* ThrobberView.m in Sources */,
 				AD055E4A2B72346E0035F824 /* KMBookmarkSheetView.swift in Sources */,
 				9F0CB4F9298655E500007028 /* KMDesignToken+Border.swift in Sources */,
-				BBFDFAA62AF3899400E08AA2 /* PasswordWindowController.swift in Sources */,
 				9F0CB45F2966C9E200007028 /* KMFormPropertPanelViewController.swift in Sources */,
 				ADCFFC0229C004AD007D3657 /* KMBookMarkTableRowView.swift in Sources */,
 				ADF6B86C2A480C5F0090CB78 /* KMComparativeView.swift in Sources */,
@@ -16630,7 +16616,6 @@
 				9F8539DF29470A0700DF644E /* KMTabStripView.swift in Sources */,
 				AD055ECA2B8848400035F824 /* NSMenu_SKExtensions.m in Sources */,
 				AD9527EF295578BD0039D2BC /* KMBaseTextFieldPresenter.swift in Sources */,
-				BBFDFAA72AF3899400E08AA2 /* PasswordWindowController.swift in Sources */,
 				8942F80029260EC700389627 /* KMLeftMethodMode.swift in Sources */,
 				BB49ED1E293F4FB200C82CA2 /* KMConvertPPTsSettingView.swift in Sources */,
 				AD055E202B70B3840035F824 /* KMBookmark.swift in Sources */,
@@ -18638,7 +18623,6 @@
 				BB328B6C2B565BEC00B382C6 /* iVersion.m in Sources */,
 				AD3AAD2E2B0B6FFA00DE5FE7 /* KMCompareCoveringView.swift in Sources */,
 				BB6DD8272934D056001F0544 /* KMSecureEncryptSuccessTipView.swift in Sources */,
-				BBFDFAA82AF3899400E08AA2 /* PasswordWindowController.swift in Sources */,
 				ADAFDA782AEB5FCD00F084BC /* KMHomeHistoryCollectionItem.swift in Sources */,
 				ADAFDA052AE8BD5C00F084BC /* KMConvertURLToPDF.m in Sources */,
 				9FCFECAA2AD243C900EAD2CB /* KMBlankView.swift in Sources */,