Bläddra i källkod

【综合】系统菜单栏删除所有注释菜单入口补充

tangchao 1 år sedan
förälder
incheckning
cc1eaabe91

+ 6 - 6
PDF Office/PDF Master.xcodeproj/xcuserdata/kdanmobile.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -318,8 +318,8 @@
             filePath = "PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "1131"
-            endingLineNumber = "1131"
+            startingLineNumber = "1135"
+            endingLineNumber = "1135"
             landmarkName = "rotateAllRight(_:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -334,8 +334,8 @@
             filePath = "PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "2312"
-            endingLineNumber = "2312"
+            startingLineNumber = "2318"
+            endingLineNumber = "2318"
             landmarkName = "autoSelectContent(_:)"
             landmarkType = "7">
          </BreakpointContent>
@@ -350,8 +350,8 @@
             filePath = "PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift"
             startingColumnNumber = "9223372036854775807"
             endingColumnNumber = "9223372036854775807"
-            startingLineNumber = "2041"
-            endingLineNumber = "2041"
+            startingLineNumber = "2047"
+            endingLineNumber = "2047"
             landmarkName = "editWatermark(_:)"
             landmarkType = "7">
          </BreakpointContent>

+ 9 - 3
PDF Office/PDF Master/Class/ChromiumTabs/KMBrowserWindowController.swift

@@ -838,9 +838,6 @@ extension KMBrowserWindowController {
         KMPrint("selfSignProfile ...")
     }
 
-    @IBAction func removeAllAnnotation(_ sender: Any?) {
-        KMPrint("removeAllAnnotation ...")
-    }
     @IBAction func link(_ sender: Any?) {
         KMPrint("link ...")
     }
@@ -1631,6 +1628,15 @@ extension KMBrowserWindowController: KMSystemPDFMenuProtocol {
             document.mainViewController?.resetForm(sender)
         }
     }
+    
+    @IBAction func removeAllAnnotation(_ sender: Any?) {
+        if (self.canResponseDocumentAction() == false) {
+            return
+        }
+        if let document = self.browser.activeTabContents() as? KMMainDocument, document.isHome == false {
+            document.mainViewController?.removeAllAnnotation(sender)
+        }
+    }
 }
 
 // MARK: - KMSystemGotoMenuProtocol

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.h

@@ -44,6 +44,7 @@
 - (NSUInteger)currentPageIndexAndPoint:(NSPoint *)point rotated:(BOOL *)rotated;
 
 - (void)resetFormAnnotation;
+- (void)removeAllAnnotation;
 
 @end
 

+ 35 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -549,6 +549,41 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
     }
 }
 
+- (void)removeAllAnnotation {
+    NSAlert* alert = [[NSAlert alloc] init];
+    [alert setAlertStyle:NSAlertStyleCritical];
+    [alert setMessageText:NSLocalizedString(@"This will permanently remove all annotations. Are you sure to continue?", nil)];
+    [alert addButtonWithTitle:NSLocalizedString(@"Yes", nil)];
+    [alert addButtonWithTitle:NSLocalizedString(@"No", nil)];
+    
+    NSModalResponse response = [alert runModal];
+    if (response == NSAlertFirstButtonReturn) {
+        NSMutableArray *annotations = [NSMutableArray array];
+        
+        for (NSUInteger i = 0; i < self.document.pageCount; i++) {
+            CPDFPage *page = [[self document] pageAtIndex:i];
+            for (CPDFAnnotation *annotation in [page annotations]) {
+                if ([annotation isKindOfClass:[CPDFTextWidgetAnnotation class]] ||
+                    [annotation isKindOfClass:[CPDFButtonWidgetAnnotation class]] ||
+                    [annotation isKindOfClass:[CPDFChoiceWidgetAnnotation class]] ||
+                    [annotation isKindOfClass:[CPDFInkAnnotation class]]) {
+                    continue;
+                }
+//                if (@available(macOS 10.13, *)) {
+//                    if ([annotation.widgetFieldType isEqualToString:PDFAnnotationWidgetSubtypeSignature]) {
+//                        continue;
+//                    }
+//                }
+                [annotations addObject:annotation];
+            }
+        }
+        
+        for (CPDFAnnotation *annotation in annotations) {
+            [self removeAnnotation:annotation];
+        }
+    }
+}
+
 @end
 
 @implementation CPDFView (KMExtension)

+ 4 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+MenuAction.swift

@@ -652,6 +652,10 @@ extension KMMainViewController: KMSystemPDFMenuProtocol {
     func resetForm(_ sender: Any?) {
         self.listView.resetFormAnnotation()
     }
+    
+    func removeAllAnnotation(_ sender: Any?) {
+        self.listView.removeAllAnnotation()
+    }
 }
 
 // MARK: goto Menu

+ 3 - 1
PDF Office/PDF Master/Class/SystemMenu/KMSystemPDFMenu.swift

@@ -24,6 +24,7 @@ import Cocoa
     @objc optional func highlightFormFiled(_ sender: Any?)
     @objc optional func highlightLinks(_ sender: Any?)
     @objc optional func resetForm(_ sender: Any?)
+    @objc optional func removeAllAnnotation(_ sender: Any?)
 }
 
 extension KMSystemMenu.PDF {
@@ -44,11 +45,12 @@ extension KMSystemMenu.PDF {
     public static let highlightLinksSelector    = NSSelectorFromString("highlightLinks:")
     
     public static let resetFormSelector    = NSSelectorFromString("resetForm:")
+    public static let removeAllAnnotationSelector    = NSSelectorFromString("removeAllAnnotation:")
     
     public static func actions() -> [Selector] {
         return [self.changeDisplayModeSelector, self.toggleDisplayAsBookSelector, self.toggleDisplayPageBreaksSelector, self.changeDisplayBoxSelector,
                 self.toggleAutoScaleSelector, self.doZoomToActualSizeSelector, self.doZoomToFitSelector, self.doZoomInSelector, self.doZoomOutSelector, self.doMarqueeZoomToolSelector,
                 self.highlightFormFiledSelector, self.highlightLinksSelector,
-                self.resetFormSelector]
+                self.resetFormSelector, self.removeAllAnnotationSelector]
     }
 }