Browse Source

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

tangchao 10 months ago
parent
commit
8958ff7d43

+ 4 - 4
PDF Office/PDF Master/Class/Home/View/HomeContentView/KMHomeContentView.xib

@@ -39,7 +39,7 @@
                                 <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                 <subviews>
                                     <customView translatesAutoresizingMaskIntoConstraints="NO" id="PAa-wQ-E8L">
-                                        <rect key="frame" x="0.0" y="294" width="569" height="262"/>
+                                        <rect key="frame" x="0.0" y="314" width="569" height="262"/>
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="69z-SV-dL5">
                                                 <rect key="frame" x="0.0" y="238" width="569" height="24"/>
@@ -132,10 +132,10 @@
                                         </constraints>
                                     </customView>
                                     <customView translatesAutoresizingMaskIntoConstraints="NO" id="lCh-WA-G58">
-                                        <rect key="frame" x="0.0" y="0.0" width="569" height="246"/>
+                                        <rect key="frame" x="0.0" y="0.0" width="569" height="266"/>
                                         <subviews>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="Q84-po-tiv">
-                                                <rect key="frame" x="0.0" y="222" width="569" height="24"/>
+                                                <rect key="frame" x="0.0" y="242" width="569" height="24"/>
                                                 <subviews>
                                                     <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Jq6-Hl-amd">
                                                         <rect key="frame" x="-2" y="0.0" width="85" height="24"/>
@@ -210,7 +210,7 @@
                                                 </constraints>
                                             </customView>
                                             <customView translatesAutoresizingMaskIntoConstraints="NO" id="wMw-AS-5yG" customClass="KMHomeHistoryListView" customModule="PDF_Reader_Pro" customModuleProvider="target">
-                                                <rect key="frame" x="0.0" y="0.0" width="569" height="222"/>
+                                                <rect key="frame" x="0.0" y="0.0" width="569" height="242"/>
                                             </customView>
                                         </subviews>
                                         <constraints>

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Crop/KMPDFCropWindowController.swift

@@ -531,7 +531,7 @@ class KMPDFCropWindowController: NSWindowController, CPDFViewDelegate, NSWindowD
 
         let tDocuemnt = CPDFDocument()
         for i in 0..<(self.originalDocument?.pageCount ?? 0) {
-            if let page = self.originalDocument?.page(at: i)?.copy() {
+            if let page = self.originalDocument?.page(at: i) {
                 tDocuemnt?.insertPageObject(page as? CPDFPage, at: tDocuemnt?.pageCount ?? 0)
             }
         }

+ 7 - 0
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.swift

@@ -210,6 +210,13 @@ class KMToolbarViewController: NSViewController, NSTextFieldDelegate {
                 KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
                 return
             }
+            if !self.pdfView.document!.allowsPrinting || !self.pdfView.document!.allowsCopying {
+                let alert = NSAlert()
+                alert.alertStyle = .critical
+                alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+                alert.runModal()
+                return
+            }
             Task { @MainActor in
                 self.delegate?.toolbarViewController?(self, clickMode: tag, toolbar: item.clickObject as! KMToolbarItemView, [])
             }

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

@@ -3855,6 +3855,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
         
         Task { @MainActor in
             if (type == .compress) { /// 压缩
+                if !self.documentAllowsEdit() {
+                    return
+                }
+                
                 if await (KMLightMemberManager.manager.canPayFunction() == false) {
 //                    self.view.window?.contentView?.superview?.beginLoading()
                     let document = self.listView.document
@@ -3919,36 +3923,38 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             
             if (type == .merge) { /// 合并
                 FMTrackEventManager.defaultManager.trackEvent(event: "SubTbr_Editor", withProperties: ["SubTbr_Btn": "Btn_SubTbr_Editor_Merge"])
-                if (self.listView.document.allowsCopying == false || self.listView.document.allowsPrinting == false) {
-                    if await (KMLightMemberManager.manager.canPayFunction() == false) {
-                            KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
-                                if (result == .cancel) {
-                                    return
-                                }
-                                 
-                                guard let _url =  KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
-                                    return
-                                }
-                                self.showMergeWindow(url: _url, password)
-                            }
-                        return
-                    }
+                if !self.documentAllowsEdit() {
+                    return
                     
-                    KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
-                        if (result == .cancel) {
-                            return
-                        }
-  
-                            
-                        if (self.needSaveDocument()) {
-                            self.saveDocumentWithProgressAlert { [unowned self] params in
-                                self.showMergeWindow(password)
-                            }
-                            return
-                        }
-                        
-                        self.showMergeWindow(password)
-                    }
+//                    if await (KMLightMemberManager.manager.canPayFunction() == false) {
+//                            KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
+//                                if (result == .cancel) {
+//                                    return
+//                                }
+//                                 
+//                                guard let _url =  KMTools.saveWatermarkDocumentToTemp(document: self.listView.document, secureOptions: self.secureOptions, removePWD: self.removeSecureFlag) else {
+//                                    return
+//                                }
+//                                self.showMergeWindow(url: _url, password)
+//                            }
+//                        return
+//                    }
+//                    
+//                    KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner, url: self.listView.document.documentURL) { [unowned self] result , password in
+//                        if (result == .cancel) {
+//                            return
+//                        }
+//  
+//                            
+//                        if (self.needSaveDocument()) {
+//                            self.saveDocumentWithProgressAlert { [unowned self] params in
+//                                self.showMergeWindow(password)
+//                            }
+//                            return
+//                        }
+//                        
+//                        self.showMergeWindow(password)
+//                    }
                     return
                 }
                 
@@ -3971,10 +3977,16 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             }
             
             if (type == .bates || type == .headerAndFooter) {
+                
                 if !IAPProductsManager.default().isAvailableAllFunction(){
                     KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
                     return
                 }
+                
+                if !self.documentAllowsEdit() {
+                    return
+                }
+                
                 if (index == 1) {
                     var windowController: KMBaseWindowController = KMBaseWindowController()
                     
@@ -4209,18 +4221,22 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             } else if (type == .secure) { /// 安全
                 if (index == 1) { /// 设置密码
                     if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
-                        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?.showSecureWindow((self?.listView.document.documentURL)!)
+                        if !self.documentAllowsEdit() {
+                            return
                         }
-                        return
+                        
+//                        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?.showSecureWindow((self?.listView.document.documentURL)!)
+//                        }
+//                        return
                     }
                     self.showSecureWindow(self.listView.document.documentURL)
                     return
@@ -4370,6 +4386,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
                 
+                if !self.documentAllowsEdit() {
+                    return
+                }
+                
                 if index == 1 {
                     let controller = KMWatermarkWindowController(windowNibName: "KMWatermarkWindowController")
                     self.currentWindowController = controller
@@ -4462,7 +4482,11 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
                     return
                 }
-                           
+                
+                if !self.documentAllowsEdit() {
+                    return
+                }
+                
                 if index == 1 {
                     let controller = KMBackgroundWindowController(windowNibName: "KMBackgroundWindowController")
                     self.currentWindowController = controller
@@ -4594,6 +4618,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 } else if itemID == KMDocumentScanOCRToolbarItemIdentifier {
                     showOCRWindow()
                 } else if itemID == KMDocumentDigitalSignToolbarItemIdentifier {
+                    if !self.listView.document!.allowsPrinting || !self.listView.document!.allowsCopying {
+                        let alert = NSAlert()
+                        alert.alertStyle = .critical
+                        alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+                        alert.runModal()
+                        return
+                    }
                     self.listView.toolMode = .textToolMode
                     toolbarItem.isSelected = !toolbarItem.isSelected
                     self.toolbarController.lastItemBox = toolbarItem
@@ -5363,3 +5394,18 @@ extension KMMainViewController {
         }
     }
 }
+
+extension KMMainViewController {
+    func documentAllowsEdit() -> Bool {
+        if (self.listView.document.allowsCopying == false || self.listView.document.allowsPrinting == false) {
+            
+            let alert = NSAlert()
+            alert.alertStyle = .critical
+            alert.messageText = NSLocalizedString("This is a secured document. Editing is not permitted.", comment: "")
+            alert.runModal()
+            return false
+        } else {
+            return true
+        }
+    }
+}

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

@@ -673,7 +673,8 @@ extension KMMainViewController {
             readAlertView?.removeFromSuperview()
         }
         readAlertView = CustomAlertView.alertView(message: NSLocalizedString("Read Mode On", comment: ""), fromView: self.view, withStyle: .blue, backgroundColor: NSColor.km_init(hex: "#36383B"))
-        self.updateAITipViewShowState()
+//        self.updateAITipViewShowState()
+        self.aiTipView.isHidden = true
     }
     
     @objc func closeReadModel() {

File diff suppressed because it is too large
+ 196 - 323
PDF Office/PDF Reader Pro.xcodeproj/xcuserdata/lizhe.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist