Browse Source

【2025】【右键菜单】代码自测修改

dinglingui 2 months ago
parent
commit
e59bef0583

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

@@ -55,6 +55,7 @@ static inline NSRect SKRectFromPoints(NSPoint aPoint, NSPoint bPoint) {
 - (IBAction)cut:(id)sender;
 - (IBAction)copy:(id)sender;
 - (IBAction)paste:(id)sender;
+- (void)menuPointPaste:(NSPoint)pagePoint page:(CPDFPage *)page isRightPaste:(BOOL)isRightPaste;
 - (IBAction)delete:(id)sender;
 - (void)exportPDF: (NSImage *)image;
 

+ 23 - 18
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+Event.m

@@ -5150,27 +5150,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     [self menuItemClick_Paste:nil];
 }
 
-- (IBAction)menuItemClick_Paste:(NSMenuItem *)sender {
+- (void)menuPointPaste:(NSPoint)pagePoint page:(CPDFPage *)page isRightPaste:(BOOL)isRightPaste{
     if ([self hideNotes]) {
         NSBeep();
         return;
     }
-    CPDFPage *page = self.currentPage;
-    CGPoint pagePoint = CGPointZero;
-    BOOL isRightPaste = YES;
-    if(sender) {
-        NSEvent * event= sender.representedObject;
-        page = [self pageAndPoint:&pagePoint forEvent:event nearest:YES];
-        if(self.currentSelection) {
-            pagePoint = self.currentSelection.bounds.origin;
-        }
-    } else {
-        CGRect visibleRect = self.scrollView.visibleRect;
-        pagePoint = CPDFlistViewCenterPoint(visibleRect);
-        
-        pagePoint = [self convertPoint:pagePoint toPage:self.currentPage];
-        isRightPaste = NO;
-    }
     NSPasteboard *pboard = [NSPasteboard generalPasteboard];
     NSDictionary *options = [NSDictionary dictionary];
     NSArray *newAnnotations = nil;
@@ -5217,7 +5201,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             
             for (CPDFAnnotation * an in self.aCopyAnnotations) {
                 NSRect bounds = CGRectZero;
-                if (sender) {
+                if (isRightPaste) {
                     CGPoint point = CPDFListViewSubstractPoints(an.bounds.origin, selectAnnotationBounds.origin);
                     if([an isKindOfClass:[CPDFStampAnnotation class]] && self.aCopyAnnotations.count == 1) {
                         bounds = CGRectMake(pagePoint.x + point.x-[an bounds].size.width/2, pagePoint.y-[an bounds].size.height/2+point.y, [an bounds].size.width,  [an bounds].size.height);
@@ -5476,6 +5460,27 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     }
 }
 
+- (IBAction)menuItemClick_Paste:(NSMenuItem *)sender {
+    CPDFPage *page = self.currentPage;
+    CGPoint pagePoint = CGPointZero;
+    BOOL isRightPaste = YES;
+    if(sender) {
+        NSEvent * event= sender.representedObject;
+        page = [self pageAndPoint:&pagePoint forEvent:event nearest:YES];
+        if(self.currentSelection) {
+            pagePoint = self.currentSelection.bounds.origin;
+        }
+    } else {
+        CGRect visibleRect = self.scrollView.visibleRect;
+        pagePoint = CPDFlistViewCenterPoint(visibleRect);
+        
+        pagePoint = [self convertPoint:pagePoint toPage:self.currentPage];
+        isRightPaste = NO;
+    }
+    
+    [self menuPointPaste:pagePoint page:page isRightPaste:isRightPaste];
+}
+
 - (IBAction)cut:(id)sender {
     BOOL isContinue = YES;
     if([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewHaveDocumentAttribute)]) {

+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.h

@@ -229,6 +229,8 @@ enum {
 
 @property (nonatomic, assign) BOOL isPresentationMode;
 
+@property (nonatomic, readonly) BOOL isShowSplitBar;
+
 @property (nonatomic, strong) KMDrawView *presentationDrawView;
 
 - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
@@ -391,5 +393,6 @@ enum {
 
 - (void)PDFListViewMobileAnnotationEnd:(CGPoint)point forPDFListView:(CPDFListView *)pdfListView forActiveAnnotations:(NSArray<CPDFAnnotation *> *)annotations;
 
+- (BOOL)PDFListViewSplitModeShowBar;
 
 @end

+ 8 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.m

@@ -575,6 +575,14 @@ void CPDFListViewOCDrawLineHandles(CGContextRef context, CGRect rect, CGFloat ra
     [super setCurrentSelection:currentSelection];
 }
 
+- (BOOL)isShowSplitBar {
+    if ([self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewSplitModeShowBar)]) {
+        return [self.pdfListViewDelegate PDFListViewSplitModeShowBar];
+    }
+    
+    return NO;
+}
+
 #pragma mark - menu add image
 - (void)addImageAnnotation:(NSImage *)image center:(NSPoint)center isRemoveBGColor:(BOOL)isRemoveBGColor{
     [self setToolMode:CTextToolMode]; //不支持重复添加,重置状态

+ 26 - 7
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -2970,8 +2970,9 @@ extension KMMainViewController {
      
     
     //MARK: - Redact密文
-    func showRedactProperty() {
+    func showRedactProperty(readactAnnotation: CPDFRedactAnnotation?) {
         let properties = KMRedactPropertiesWindowController()
+        properties.readactAnnotation = readactAnnotation
         self.km_beginSheet(windowC: properties)
         
     }
@@ -3381,7 +3382,7 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
             if itemIdentifier == KMPDFToolbar_protect_redact_Identifier {
                 
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Property_Identifier {
-                self.showRedactProperty()
+                self.showRedactProperty(readactAnnotation: nil)
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Apply_Identifier {
                 
             } else if itemIdentifier == KMPDFToolbar_protect_redact_Exit_Identifier {
@@ -4577,7 +4578,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         
         let isShowPopUI:Bool = false
 
-        if let page = listView.pageAndPoint(&pagePoint, for: theEvent, nearest: false) {
+        if let page = pdfListView.pageAndPoint(&pagePoint, for: theEvent, nearest: false) {
             if view.window?.interactionMode == .presentation {
                 let menuStruct = clickPresentationMenu(point: pagePoint)
                 groupListMenuGroup?.groupDelegate = self
@@ -4647,7 +4648,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                         menuStringArr.append(PDFViewMenuIdentifier_Redact_Apply)
                         menuStringArr.append(PDFViewMenuIdentifier_Redact_Multipage)
                         menuStringArr.append(PDFViewMenuIdentifier_Space)
-                        menuStringArr.append(PDFViewMenuIdentifier_Normal_Properties)
+                        menuStringArr.append(PDFViewMenuIdentifier_Normal_RedactProperties)
                         menuStringArr.append(PDFViewMenuIdentifier_Redact_Default)
                     } else if listView.activeAnnotation.isKind(of: CPDFLinkAnnotation.self) {
                         let link = listView.activeAnnotation as? CPDFLinkAnnotation
@@ -4689,6 +4690,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_ShowPopUI)
                             menuStringArr.append(PDFViewMenuIdentifier_Space)
                         }
+                        menuStringArr.append(PDFViewMenuIdentifier_Normal_SortAnnotation)
                     }
                 } else {
                     let currentSelection = pdfListView.currentSelection
@@ -4700,6 +4702,7 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
                             if pdfListView.canPaste() {
                                 menuStringArr.append(PDFViewMenuIdentifier_Normal_Past)
                             }
+                            menuStringArr.append(PDFViewMenuIdentifier_Space)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Hight)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_Underline)
                             menuStringArr.append(PDFViewMenuIdentifier_Normal_StrikeOut)
@@ -5133,6 +5136,10 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         }
     }
     
+    func pdfListViewSplitModeShowBar()->Bool {
+        return viewManager.splitShowBottomBar
+    }
+        
     //MARK: -Crop
     func pdfListViewChangedSelectionOrMagnification(_ pdfListView: CPDFListView!) {
         reloadPopUIWindow()
@@ -5188,6 +5195,8 @@ extension KMMainViewController: CPDFViewDelegate,CPDFListViewDelegate {
         cancelMeasureType()
     }
     
+    
+    
     private func handleLineAnnotation(_ annotation: CPDFLineAnnotation) {
         if perimeterMeasureInfoWindowController?.window?.isVisible == true {
             perimeterMeasureInfoWindowController?.hideFloatingWindow()
@@ -5485,7 +5494,14 @@ extension KMMainViewController: ComponentGroupDelegate {
                 kmPDFSideBarControllerDidSidebarTypeUpdated(sideVC)
             }
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_Past) {
-            listView.copy(nil)
+            let theEvent = menuItemProperty?.representedObject
+            
+            if let currentEvent = theEvent as? NSEvent {
+                var pagePoint = CGPoint.zero
+                if let page = listView.pageAndPoint(&pagePoint, for: currentEvent, nearest: false) {
+                    listView.menuPointPaste(pagePoint, page: page, isRightPaste: true)
+                }
+            }
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_SelectAllText) {
             listView.selectAll(nil)
         } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_AddBook) {
@@ -5614,8 +5630,7 @@ extension KMMainViewController: ComponentGroupDelegate {
                 }
             }
         } else if(menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_EnterPageNum) {
-            
-            
+            sideBarController?.beginEditing()
         } else if(menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_PageBack) {
             if let objectListView = menuItemProperty?.representedObject as? CPDFListView {
                 if(objectListView.canGoBack() == true) {
@@ -5935,6 +5950,10 @@ extension KMMainViewController: ComponentGroupDelegate {
             listView.cropAction()
         } else if(menuItemProperty?.identifier == PDFViewMenuIdentifier_Edit_Replace) {
             listView.replaceImageEdit()
+        } else if (menuItemProperty?.identifier == PDFViewMenuIdentifier_Normal_RedactProperties) {
+            if let redactAnnotation = listView.activeAnnotation as? CPDFRedactAnnotation{
+                showRedactProperty(readactAnnotation: redactAnnotation)
+            }
         }
         
     }

+ 15 - 2
PDF Office/PDF Master/KMClass/KMPDFViewController/KMPDFMenuConfig.swift

@@ -141,6 +141,7 @@ let PDFViewMenuIdentifier_Normal_Export = "PDFViewMenuIdentifier_Normal_Export"
 let PDFViewMenuIdentifier_Normal_ExportJPG = "PDFViewMenuIdentifier_Normal_ExportJPG"
 let PDFViewMenuIdentifier_Normal_ExportPNG = "PDFViewMenuIdentifier_Normal_ExportPNG"
 let PDFViewMenuIdentifier_Normal_ExportPDF = "PDFViewMenuIdentifier_Normal_ExportPDF"
+let PDFViewMenuIdentifier_Normal_RedactProperties = "PDFViewMenuIdentifier_Normal_RedactProperties"
 
 let PDFViewMenuIdentifier_Edit_Paste = "PDFViewMenuIdentifier_Edit_Paste"
 let PDFViewMenuIdentifier_Edit_NoStylePaste = "PDFViewMenuIdentifier_Edit_NoStylePaste"
@@ -819,6 +820,9 @@ let PDFViewMenuIdentifier_Edit_Replace = "PDFViewMenuIdentifier_Edit_Replace"
         let propertie_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(keyEquivalent: nil,
                                                                                        text: KMLocalizedString("Show Status Bar"),
                                                                                        identifier: PDFViewMenuIdentifier_Split_ShowBar,representedObject: listView)
+        if(listView?.isShowSplitBar == true) {
+            propertie_Menuitem.righticon = NSImage(named: "KMNImageNameMenuSelect")
+        }
         return propertie_Menuitem
     }
     
@@ -895,7 +899,7 @@ let PDFViewMenuIdentifier_Edit_Replace = "PDFViewMenuIdentifier_Edit_Replace"
     class func editPastProperty(theEvent:NSEvent?,listView:CPDFListView?)->ComponentMenuitemProperty {
         let past_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(keyEquivalent: "⌘V",
                                                                                        text: KMLocalizedString("Paste and Match Style"),
-                                                                                       identifier: PDFViewMenuIdentifier_Normal_Past,representedObject: theEvent)
+                                                                                       identifier: PDFViewMenuIdentifier_Edit_Paste,representedObject: theEvent)
         
       return past_Menuitem
     }
@@ -903,7 +907,7 @@ let PDFViewMenuIdentifier_Edit_Replace = "PDFViewMenuIdentifier_Edit_Replace"
     class func editPastNoStyleProperty(theEvent:NSEvent?,listView:CPDFListView?)->ComponentMenuitemProperty {
         let propertie_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(keyEquivalent: "⇧⌘V",
                                                                                        text: KMLocalizedString("Paste"),
-                                                                                       identifier: PDFViewMenuIdentifier_Split_ShowBar,representedObject: listView)
+                                                                                       identifier: PDFViewMenuIdentifier_Edit_NoStylePaste,representedObject: listView)
         return propertie_Menuitem
     }
     
@@ -1074,6 +1078,13 @@ let PDFViewMenuIdentifier_Edit_Replace = "PDFViewMenuIdentifier_Edit_Replace"
         return propertie_Menuitem
     }
     
+    class func redactPropertiesProperty(theEvent:NSEvent?,listView:CPDFListView?)->ComponentMenuitemProperty {
+        let propertie_Menuitem: ComponentMenuitemProperty = ComponentMenuitemProperty(keyEquivalent: nil,
+                                                                                       text: KMLocalizedString("Properties..."),
+                                                                                       identifier: PDFViewMenuIdentifier_Normal_RedactProperties,representedObject: listView)
+        return propertie_Menuitem
+    }
+    
     class func clickMenuUI(items:[String],theEvent:NSEvent?,listView:CPDFListView?)->KMNMenuStruct {
         var viewHeight: CGFloat = 8
         var menuItemArr: [ComponentMenuitemProperty] = []
@@ -1205,6 +1216,8 @@ let PDFViewMenuIdentifier_Edit_Replace = "PDFViewMenuIdentifier_Edit_Replace"
                 menuItemArr.append(KMPDFMenuConfig.editCropProperty(theEvent: theEvent, listView: listView))
             } else if item == PDFViewMenuIdentifier_Edit_Replace {
                 menuItemArr.append(KMPDFMenuConfig.editReplaceProperty(theEvent: theEvent, listView: listView))
+            } else if item == PDFViewMenuIdentifier_Normal_RedactProperties {
+                menuItemArr.append(KMPDFMenuConfig.redactPropertiesProperty(theEvent: theEvent, listView: listView))
             }
             
             if(item == PDFViewMenuIdentifier_Space) {