Browse Source

【2025】【PDFView】选中文本大纲崩溃问题修改

dinglingui 3 weeks ago
parent
commit
5ba0c07ae7

+ 25 - 9
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -3307,6 +3307,8 @@ struct KMNMWCFlags {
     
     //MARK: - 新增大纲
     @objc func addOutLineItemAction() {
+        toggleOpenLeftSide(pdfSideBarType: .outline)
+        
         botaViewController?.outlineViewC.addOutline()
     }
     
@@ -3391,7 +3393,7 @@ struct KMNMWCFlags {
         var formActiveAnnotations:[CPDFAnnotation] = []
         for i in 0 ..< listView.document.pageCount {
             let page = listView.document.page(at: i)
-            if(page?.pageIndex() = currentPage.pageIndex()) {
+            if(page?.pageIndex() == currentPage.pageIndex()) {
                 let annotations = page?.annotations
                 for j in 0 ..< (annotations?.count ?? 0) {
                     if let an = annotations?[j] as? CPDFAnnotation {
@@ -3409,7 +3411,7 @@ struct KMNMWCFlags {
         var normalActiveAnnotations:[CPDFAnnotation] = []
         for i in 0 ..< listView.document.pageCount {
             let page = listView.document.page(at: i)
-            if(page?.pageIndex() = currentPage.pageIndex()) {
+            if(page?.pageIndex() == currentPage.pageIndex()) {
                 let annotations = page?.annotations
                 for j in 0 ..< (annotations?.count ?? 0) {
                     if let an = annotations?[j] as? CPDFAnnotation {
@@ -3426,15 +3428,18 @@ struct KMNMWCFlags {
         listView.updateActiveAnnotations(normalActiveAnnotations)
     }
     
-    @objc func selectAllRedactAnnotation () {
+    @objc func selectAllRedactAnnotation (currentPage:CPDFPage) {
         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)
+            if(page?.pageIndex() == currentPage.pageIndex()) {
+                
+                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)
+                        }
                     }
                 }
             }
@@ -6846,7 +6851,18 @@ extension KMMainViewController: ComponentGroupDelegate {
             }
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_SelectAllText) {
             if self.listView.toolMode == .CRedactToolMode {
-                self.selectAllRedactAnnotation()
+                if let dic = menuItemProperty?.representedObject as? NSDictionary {
+                    let objectListView = dic["Object"] as? CPDFListView
+                    let theEvent = dic["theEvent"] as? NSEvent
+                    
+                    if(objectListView != nil && theEvent != nil) {
+                        var pagePoint = CGPoint.zero
+                        if let page = objectListView?.pageAndPoint(&pagePoint, for: theEvent, nearest: false) {
+                            
+                            self.selectAllRedactAnnotation(currentPage: page)
+                        }
+                    }
+                }
             } else {
                 listView.selectAll(nil)
             }

+ 1 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/KMPDFMenuConfig.swift

@@ -508,7 +508,7 @@ let BOTAMenuIdentifier_Annotation_DeleteMuteRep = "BOTAMenuIdentifier_Annotation
     class func seletAllMenuItemProperty(theEvent:NSEvent?,listView:CPDFListView?)->ComponentMenuitemProperty {
         let selectAll_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(keyEquivalent: "⌘A",
                                                                                        text: KMLocalizedString("Select All"),
-                                                                                       identifier: PDFViewMenuIdentifier_Normal_SelectAllText,representedObject: listView)
+                                                                                       identifier: PDFViewMenuIdentifier_Normal_SelectAllText,representedObject: ["Object": listView, "theEvent": theEvent])
         return selectAll_Menuitem
     }