浏览代码

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

niehaoyu 1 月之前
父节点
当前提交
aef909d7c6

+ 34 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -3449,6 +3449,23 @@ struct KMNMWCFlags {
         listView.updateActiveAnnotations(normalActiveAnnotations)
     }
     
+    @objc func selectAllRedactAnnotation () {
+        var selectAllRedactAnnotation: [CPDFAnnotation] = []
+        for i in 0 ..< listView.document.pageCount {
+            let page = listView.document.page(at: i)
+            let annotations = page?.annotations
+            for j in 0 ..< (annotations?.count ?? 0) {
+                if let an = annotations?[j] as? CPDFAnnotation {
+                    if an.isKind(of: CPDFRedactAnnotation.self) == true {
+                        selectAllRedactAnnotation.append(an)
+                    }
+                }
+            }
+        }
+        listView.updateActiveAnnotations(selectAllRedactAnnotation)
+        listView.setNeedsDisplayForVisiblePages()
+    }
+    
     //MARK: 搜索 & 替换
     func showSearchPopWindow(type: KMNBotaSearchType, keyborad: String?, replaceText: String?, results: [KMSearchMode]) {
         let toolMode = self.listView.toolMode
@@ -5714,6 +5731,11 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_CopyText)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Delete)
                             menuStringArr.append(PDFViewMenuIdentifier_Space)
+                        } else if firstAnnotation?.isKind(of: CPDFRedactAnnotation.self) == true {
+                            menuStringArr.append(PDFViewMenuIdentifier_Normal_Delete)
+                            menuStringArr.append(PDFViewMenuIdentifier_Space)
+                            menuStringArr.append(PDFViewMenuIdentifier_Redact_Apply)
+                            menuStringArr.append(PDFViewMenuIdentifier_Redact_Multipage)
                         } else {
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Copy)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Cut)
@@ -5725,7 +5747,13 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_ShowPopUI)
                             menuStringArr.append(PDFViewMenuIdentifier_Space)
                         }
-                        menuStringArr.append(PDFViewMenuIdentifier_Normal_SortAnnotation)
+                        
+                        if firstAnnotation?.isKind(of: CPDFRedactAnnotation.self) == true {
+                            
+                        } else {
+                            menuStringArr.append(PDFViewMenuIdentifier_Normal_SortAnnotation)
+                        }
+                        
                         if firstAnnotation?.isKind(of: CPDFLinkAnnotation.self) == true || firstAnnotation?.isKind(of: CPDFWidgetAnnotation.self) == true  {
                             menuStringArr.append(PDFViewMenuIdentifier_Space)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Aligning)
@@ -6656,7 +6684,11 @@ extension KMMainViewController: ComponentGroupDelegate {
                 }
             }
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_SelectAllText) {
-            listView.selectAll(nil)
+            if self.listView.toolMode == .CRedactToolMode {
+                self.selectAllRedactAnnotation()
+            } else {
+                listView.selectAll(nil)
+            }
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_AddBook) {
             menuItemBookMarkClick_add(sender: nil)
         } else if(menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_TextTool) {

+ 22 - 7
PDF Office/PDF Master/KMClass/KMPDFViewController/Toolbar/KMPDFToolbarController.swift

@@ -1313,16 +1313,31 @@ extension KMPDFToolbarController: KMRedactToolbarControllerDelegate {
 //            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Apply_Identifier)
             
         } else if buttonIndex == 3 {
-            self.exitRedactAlert()
-//            viewManager?.subToolMode = .None
-//            cancelSelectedSecondToolbarItems(.Protect)
-//            delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
-            
+            if self.existRedactAnnotation() {
+                self.exitRedactAlert()
+            } else {
+                viewManager?.subToolMode = .None
+                cancelSelectedSecondToolbarItems(.Protect)
+                delegate?.kmPDFToolbarControllerDidToolbarItemClicked?(self, KMPDFToolbar_protect_redact_Exit_Identifier)
+            }
         }
         
         reloadData()
-        
-        
+    }
+    
+    func existRedactAnnotation() -> Bool {
+        for i in 0 ..< (pdfView?.document.pageCount ?? 0) {
+            let page = pdfView?.document.page(at: i)
+            let annotations = page?.annotations
+            for j in 0 ..< (annotations?.count ?? 0) {
+                if let an = annotations?[j] as? CPDFAnnotation {
+                    if an.isKind(of: CPDFRedactAnnotation.self) == true {
+                        return true
+                    }
+                }
+            }
+        }
+        return false
     }
     
     func exitRedactAlert() {