Jelajahi Sumber

【OCToSwift】NSEvent+PDFListView

tangchao 1 tahun lalu
induk
melakukan
5040765c16

+ 0 - 10
PDF Office/PDF Master.xcodeproj/project.pbxproj

@@ -3267,9 +3267,6 @@
 		F34BF93529530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
 		F34BF93629530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
 		F34BF93729530708002C25A2 /* NSImage+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93429530708002C25A2 /* NSImage+PDFListView.m */; };
-		F34BF93A29530951002C25A2 /* NSEvent+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93929530951002C25A2 /* NSEvent+PDFListView.m */; };
-		F34BF93B29530951002C25A2 /* NSEvent+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93929530951002C25A2 /* NSEvent+PDFListView.m */; };
-		F34BF93C29530951002C25A2 /* NSEvent+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93929530951002C25A2 /* NSEvent+PDFListView.m */; };
 		F34BF93F29530D02002C25A2 /* NSBezierPath+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93E29530D02002C25A2 /* NSBezierPath+PDFListView.m */; };
 		F34BF94029530D02002C25A2 /* NSBezierPath+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93E29530D02002C25A2 /* NSBezierPath+PDFListView.m */; };
 		F34BF94129530D02002C25A2 /* NSBezierPath+PDFListView.m in Sources */ = {isa = PBXBuildFile; fileRef = F34BF93E29530D02002C25A2 /* NSBezierPath+PDFListView.m */; };
@@ -4811,7 +4808,6 @@
 		F34BF925295303E8002C25A2 /* NSCursor+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSCursor+PDFListView.m"; sourceTree = "<group>"; };
 		F34BF93329530708002C25A2 /* NSImage+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSImage+PDFListView.h"; sourceTree = "<group>"; };
 		F34BF93429530708002C25A2 /* NSImage+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSImage+PDFListView.m"; sourceTree = "<group>"; };
-		F34BF93929530951002C25A2 /* NSEvent+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSEvent+PDFListView.m"; sourceTree = "<group>"; };
 		F34BF93D29530D02002C25A2 /* NSBezierPath+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSBezierPath+PDFListView.h"; sourceTree = "<group>"; };
 		F34BF93E29530D02002C25A2 /* NSBezierPath+PDFListView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSBezierPath+PDFListView.m"; sourceTree = "<group>"; };
 		F34BF947295310AB002C25A2 /* NSUserDefaults+PDFListView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSUserDefaults+PDFListView.h"; sourceTree = "<group>"; };
@@ -4837,7 +4833,6 @@
 		F36EB6C62987C9FE004C25FB /* KMDocumentAIViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KMDocumentAIViewController.h; sourceTree = "<group>"; };
 		F36EB6C72987C9FE004C25FB /* KMDocumentAIViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KMDocumentAIViewController.m; sourceTree = "<group>"; };
 		F36EB6C82987C9FE004C25FB /* KMDocumentAIViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = KMDocumentAIViewController.xib; sourceTree = "<group>"; };
-		F3732284292CB1150013862C /* NSEvent+PDFListView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSEvent+PDFListView.h"; sourceTree = "<group>"; };
 		F3732288292CB4030013862C /* CPDFListView+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CPDFListView+Private.h"; sourceTree = "<group>"; };
 		F37322B8292DF9410013862C /* CPDFAnnotationModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CPDFAnnotationModel.m; sourceTree = "<group>"; };
 		F37322BD292DF9410013862C /* CPDFMarkupAnnotation+PDFListView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CPDFMarkupAnnotation+PDFListView.m"; sourceTree = "<group>"; };
@@ -9070,8 +9065,6 @@
 				F34BF925295303E8002C25A2 /* NSCursor+PDFListView.m */,
 				F34BF93329530708002C25A2 /* NSImage+PDFListView.h */,
 				F34BF93429530708002C25A2 /* NSImage+PDFListView.m */,
-				F3732284292CB1150013862C /* NSEvent+PDFListView.h */,
-				F34BF93929530951002C25A2 /* NSEvent+PDFListView.m */,
 				F359921F292CA27A000D25DE /* CPDFListViewRuntime.h */,
 				F3599217292CA27A000D25DE /* CPDFListViewRuntime.m */,
 				F34BF93D29530D02002C25A2 /* NSBezierPath+PDFListView.h */,
@@ -10479,7 +10472,6 @@
 				9F1FE51129407B4000E952CA /* KMFileSearchView.swift in Sources */,
 				ADC075E1298766D9006C752F /* KMBatchConverPDFImageView.swift in Sources */,
 				BB897279294DFD1E0045787C /* KMWatermarkTextView.swift in Sources */,
-				F34BF93A29530951002C25A2 /* NSEvent+PDFListView.m in Sources */,
 				BBC3484E29582920008D2CD1 /* KMBackgroundColorView.swift in Sources */,
 				ADF1569329A62D1D001D1018 /* KMLoginLeftImageView.swift in Sources */,
 				BBA762D229D2D98D00844513 /* KMCommonDefine.swift in Sources */,
@@ -11943,7 +11935,6 @@
 				9F0CB4FE298655F600007028 /* KMDesignToken+BorderColor.swift in Sources */,
 				BBB1A3A729F6B66400E54E47 /* NSPanel+KMExtension.swift in Sources */,
 				BB147048299DC0D200784A6A /* OIDServiceConfiguration.m in Sources */,
-				F34BF93B29530951002C25A2 /* NSEvent+PDFListView.m in Sources */,
 				9F1F82BD292E01860092C4B4 /* KMCloudEmptyCollectionViewItem.swift in Sources */,
 				BBEC00CD295C31F900A26C98 /* KMBatesModel.swift in Sources */,
 				BB897219294AED6C0045787C /* KMWatermarkAdjectivePreViewBaseController.swift in Sources */,
@@ -12748,7 +12739,6 @@
 				9F1FE50129406E4700E952CA /* CTTabStripModel.m in Sources */,
 				BB35C4A12975362900D46EE2 /* KMRedactTopToolBar.swift in Sources */,
 				ADC075D129875F49006C752F /* KMBatchConverPDFExcelView.swift in Sources */,
-				F34BF93C29530951002C25A2 /* NSEvent+PDFListView.m in Sources */,
 				AD8810B429A846B100178CA1 /* KMVerficationCodeWindowController.swift in Sources */,
 				9F1FE4CB29406E4700E952CA /* CTTabContents.m in Sources */,
 				9F78EFC428F7E395001E66F4 /* KMHomeViewController+Action.swift in Sources */,

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/OCR/KMDocumentAIPDFView.m

@@ -6,9 +6,9 @@
 //
 
 #import "KMDocumentAIPDFView.h"
-#import "NSEvent+PDFListView.h"
 #import "NSGeometry+PDFListView.h"
 #import "KMDocumentAIPopViewController.h"
+#import <PDF_Master-Swift.h>
 
 #define DOCUMENT_SIZE 30.0
 

+ 0 - 25
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSEvent+PDFListView.h

@@ -1,25 +0,0 @@
-//
-//  NSEvent+PDFListView.h
-//  ComPDFKit
-//
-//  Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
-//
-//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
-//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
-//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
-//  This notice may not be removed from this file.
-//
-
-#import <Cocoa/Cocoa.h>
-
-@interface NSEvent (PDFListView)
-
-+ (NSUInteger)standardPDFListViewModifierFlags;
-
-- (NSPoint)locationInPDFListView:(NSView *)view;
-
-- (NSUInteger)standardPDFListViewModifierFlags;
-
-- (unichar)PDFListViewFirstCharacter;
-
-@end

+ 0 - 34
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/NSEvent+PDFListView.m

@@ -1,34 +0,0 @@
-//
-//  NSEvent+PDFListView.m
-//  ComPDFKit
-//
-//  Copyright © 2014-2022 PDF Technologies, Inc. All Rights Reserved.
-//
-//  THIS SOURCE CODE AND ANY ACCOMPANYING DOCUMENTATION ARE PROTECTED BY INTERNATIONAL COPYRIGHT LAW
-//  AND MAY NOT BE RESOLD OR REDISTRIBUTED. USAGE IS BOUND TO THE ComPDFKit LICENSE AGREEMENT.
-//  UNAUTHORIZED REPRODUCTION OR DISTRIBUTION IS SUBJECT TO CIVIL AND CRIMINAL PENALTIES.
-//  This notice may not be removed from this file.
-//
-
-#import "NSEvent+PDFListView.h"
-
-@implementation NSEvent (PDFListView)
-
-+ (NSUInteger)standardPDFListViewModifierFlags {
-    return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
-}
-
-- (NSPoint)locationInPDFListView:(NSView *)view {
-    return [view convertPoint:[self locationInWindow] fromView:nil];
-}
-
-- (NSUInteger)standardPDFListViewModifierFlags {
-    return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
-}
-
-- (unichar)PDFListViewFirstCharacter {
-    NSString *characters = [self charactersIgnoringModifiers];
-    return [characters length] > 0 ? [characters characterAtIndex:0] : 0;
-}
-
-@end

+ 30 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/AppKitCategories/PDFListView+KMExtensions.swift

@@ -62,6 +62,8 @@ import Foundation
     }
 }
 
+// MARK: - NSBitmapImageRep
+
 @objc extension NSBitmapImageRep {
     class func imagePDFListViewRep(size: NSSize, scale: CGFloat, drawingHandler: ((NSRect)->Void)?) -> NSBitmapImageRep? {
         var bmpImageRep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: Int(size.width * scale), pixelsHigh: Int(size.height * scale), bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false, colorSpaceName: .calibratedRGB, bitmapFormat: .alphaFirst,bytesPerRow: 0, bitsPerPixel: 0)
@@ -78,3 +80,31 @@ import Foundation
         return bmpImageRep
     }
 }
+
+// MARK: - NSEvent
+
+@objc extension NSEvent {
+    func locationInPDFListView(_ view: NSView) -> NSPoint {
+        return view.convert(self.locationInWindow, from: nil)
+    }
+    
+    func PDFListViewFirstCharacter() -> u_char {
+        if let characters = self.charactersIgnoringModifiers as? NSString {
+            if (characters.length == 0) {
+                return 0
+            }
+            characters.character(at: 0)
+        }
+        return 0
+    }
+    
+    /*
+     + (NSUInteger)standardPDFListViewModifierFlags {
+         return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
+     }
+
+     - (NSUInteger)standardPDFListViewModifierFlags {
+         return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
+     }
+     */
+}

+ 2 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -15,7 +15,6 @@
 #import "CPDFListView+Private.h"
 #import "CPDFListView+Tool.h"
 
-#import "NSEvent+PDFListView.h"
 #import "NSImage+PDFListView.h"
 #import "NSCursor+PDFListView.h"
 #import "NSBezierPath+PDFListView.h"
@@ -68,7 +67,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     NSPoint newpoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
     area = [self areaOfInterestForPoint:newpoint];
 
-    NSUInteger modifiers = [theEvent standardPDFListViewModifierFlags];
+    NSUInteger modifiers = [CPDFListView standardPDFListViewModifierFlags];
     CPDFAnnotation *newActiveAnnotation = nil;
     if ([[self document] isLocked]) {
         [super mouseDown:theEvent];
@@ -793,7 +792,7 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     if (theEvent == nil)
         theEvent = [NSEvent mouseEventWithType:NSEventTypeMouseMoved
                                       location:[[self window] mouseLocationOutsideOfEventStream]
-                                 modifierFlags:[NSEvent standardPDFListViewModifierFlags]
+                                 modifierFlags:[CPDFListView standardPDFListViewModifierFlags]
                                      timestamp:0
                                   windowNumber:[[self window] windowNumber]
                                        context:nil

+ 1 - 2
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+KeyEvent.m

@@ -13,7 +13,6 @@
 #import "CPDFListView+KeyEvent.h"
 
 #import "CPDFListView.h"
-#import "NSEvent+PDFListView.h"
 #import "CPDFListView+Event.h"
 #import "CPDFListView+Private.h"
 #import <PDF_Master-Swift.h>
@@ -22,7 +21,7 @@
 
 - (void)keyDown:(NSEvent *)theEvent {
     unichar eventChar = [theEvent PDFListViewFirstCharacter];
-    NSUInteger modifiers = [theEvent standardPDFListViewModifierFlags];
+    NSUInteger modifiers = [CPDFListView standardPDFListViewModifierFlags];
     
     BOOL isCtrlPressed = (modifiers & NSEventModifierFlagControl) == NSEventModifierFlagControl;
     if (isCtrlPressed) {

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Tool.h

@@ -83,5 +83,7 @@ typedef NS_ENUM(NSInteger, CAnnotationAlignState) {
 
 - (void)dragAnnotationReferenceLine:(CPDFAnnotation *)annotation;
 
++ (NSUInteger)standardPDFListViewModifierFlags;
+
 @end
 

+ 24 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Tool.m

@@ -16,11 +16,30 @@
 #import "CPDFListHoverAnnotationViewController.h"
 #import "NSCursor+PDFListView.h"
 
-#import "NSEvent+PDFListView.h"
 #import "NSGeometry+PDFListView.h"
 #import "CPDFAnnotationModel.h"
 #import <PDF_Master-Swift.h>
 
+@interface NSEvent (PDFListView)
+
++ (NSUInteger)standardPDFListViewModifierFlags;
+
+- (NSUInteger)standardPDFListViewModifierFlags;
+
+@end
+
+@implementation NSEvent (PDFListView)
+
++ (NSUInteger)standardPDFListViewModifierFlags {
+    return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
+}
+
+- (NSUInteger)standardPDFListViewModifierFlags {
+    return [self modifierFlags] & (NSEventModifierFlagCommand | NSEventModifierFlagOption | NSEventModifierFlagShift | NSEventModifierFlagControl);
+}
+
+@end
+
 @implementation CPDFListView (Tool)
 
 + (BOOL)isMarkupAnnotationType:(CAnnotationType)annotationType {
@@ -588,4 +607,8 @@
     return size;
 }
 
++ (NSUInteger)standardPDFListViewModifierFlags {
+    return  [NSEvent standardPDFListViewModifierFlags];
+}
+
 @end