浏览代码

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

tangchao 10 月之前
父节点
当前提交
34f567c44b

+ 4 - 0
PDF Office/PDF Master/Class/KMAdvertisement/Config/KMAdvertisementConfig.swift

@@ -114,11 +114,15 @@
     public var language: KMAdvertisementLanguageType = .unknow
     
     func activityBaseURL() -> String {
+        #if DEBUG
         if kTestMode == 1{
             return "http://test-store.kdan.cn:3019"
         } else {
             return "https://store.filmagepro.com:3018"
         }
+        #else
+        return "https://store.filmagepro.com:3018"
+        #endif
     }
     
     public func initParameters(appName: KMAdvertisementAppNameType, subscribeType:KMAdvertisementSubscribeType, platform: KMAdvertisementPlatformType) {

+ 1 - 1
PDF Office/PDF Master/Class/KMAdvertisement/Model/KMAdvertisementModel.swift

@@ -11,7 +11,7 @@
     public var recommondContent: KMAdvertisementContent?
     public var advertisement: KMAdvertisementItem?
     public var remoteControl: KMAdvertisementRemoteControl?
-    public var discountRecommond: KMAdvertisementItem?
+    public var discountContent: KMAdvertisementItem?
 }
 
 @objcMembers public class KMAdvertisementContent: NSObject, Codable {

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

@@ -16,6 +16,8 @@
 
 #define SKAnnotationKey @"SKAnnotation"
 
+extern NSString *SKPasteboardTypeLineStyle;
+
 extern NSNotificationName const CPDFListViewSelectionChangedNotification;
 
 extern NSNotificationName const CPDFListViewToolModeChangeNotification;

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

@@ -26,6 +26,8 @@
 
 #import <PDF_Reader_Pro-Swift.h>
 
+NSString *SKPasteboardTypeLineStyle = @"net.sourceforge.skim-app.pasteboard.line-style";
+
 NSNotificationName const CPDFListViewSelectionChangedNotification = @"CPDFListViewSelectionChangedNotification";
 
 NSNotificationName const CPDFListViewToolModeChangeNotification = @"CPDFListViewToolModeChangeNotification";
@@ -130,6 +132,9 @@ NSNotificationName const KMPDFViewTableAnnotationDidChangeNotification = @"KMPDF
     
     [self addTrackingArea];
     
+//    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSPasteboardTypeColor, SKPasteboardTypeLineStyle, nil]];
+    [self registerForDraggedTypes:[NSArray arrayWithObjects:NSPasteboardTypeFileURL, nil]];
+    
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handlePageChangedNotification:)
                                                  name:CPDFViewPageChangedNotification object:self];
 
@@ -1446,6 +1451,117 @@ NSNotificationName const KMPDFViewTableAnnotationDidChangeNotification = @"KMPDF
     }
 }
 
+#pragma mark NSDraggingDestination protocol
+
+- (NSDragOperation)draggingEntered:(id<NSDraggingInfo>)sender {
+    NSArray *supportArray = [NSArray arrayWithObjects:@"jpg",@"cur",@"bmp",@"jpeg",@"gif",@"png",@"tiff",@"tif",/*@"pic",*/@"ico",@"icns",@"tga",@"psd",@"eps",@"hdr",@"jp2",@"jpc",@"pict",@"sgi",@"pdf", nil];
+
+    NSPasteboard *pasteboard = [sender draggingPasteboard];
+    if ([pasteboard availableTypeFromArray:[NSArray arrayWithObject:NSFilenamesPboardType]]) {
+        NSArray *fileNames = [pasteboard propertyListForType:NSFilenamesPboardType];
+        NSString *filePath = fileNames.firstObject;
+        if (fileNames.count == 1 && [supportArray containsObject:[filePath.pathExtension lowercaseString]]) {
+            return NSDragOperationCopy;
+        }
+    }
+    return NSDragOperationNone;
+}
+
+- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender {
+    NSDragOperation dragOp = NSDragOperationNone;
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    if ([pboard canReadItemWithDataConformingToTypes:[NSArray arrayWithObjects:NSPasteboardTypeColor, SKPasteboardTypeLineStyle, nil]]) {
+        NSPoint location = [self convertPoint:[sender draggingLocation] fromView:nil];
+        CPDFPage *page = [self pageForPoint:location nearest:NO];
+        if (page) {
+            NSArray *annotations = [page annotations];
+            CPDFAnnotation *annotation = nil;
+            NSInteger i = [annotations count];
+            location = [self convertPoint:location toPage:page];
+            while (i-- > 0) {
+                annotation = [annotations objectAtIndex:i];
+                if ([self annoHitTest:location Anno:annotation] &&
+                    ([pboard canReadItemWithDataConformingToTypes:[NSArray arrayWithObjects:NSPasteboardTypeColor, nil]] || [annotation hasBorder])) {
+//                    if ([annotation isEqual:highlightAnnotation] == NO) {
+//                        if (highlightAnnotation)
+//                            [self setNeedsDisplayForAnnotation:highlightAnnotation];
+//                        [self setHighlightAnnotation:annotation];
+//                        [self setNeedsDisplayForAnnotation:highlightAnnotation];
+//                    }
+                    dragOp = NSDragOperationGeneric;
+                    break;
+                }
+            }
+        }
+        if (dragOp == NSDragOperationNone /*&& highlightAnnotation*/) {
+//            [self setNeedsDisplayForAnnotation:highlightAnnotation];
+//            [self setHighlightAnnotation:nil];
+        }
+    } else if ([[CPDFListView superclass] instancesRespondToSelector:_cmd]) {
+        dragOp = [super draggingUpdated:sender];
+    }
+    return dragOp;
+}
+
+- (BOOL)annoHitTest:(NSPoint)point Anno: (CPDFAnnotation *)anno{
+    return [anno shouldDisplay] ? NSPointInRect(point, [self bounds]) : NO;
+}
+
+- (void)draggingExited:(id <NSDraggingInfo>)sender {
+    NSPasteboard *pboard = [sender draggingPasteboard];
+    if ([pboard canReadItemWithDataConformingToTypes:[NSArray arrayWithObjects:NSPasteboardTypeColor, SKPasteboardTypeLineStyle, nil]]) {
+//        if (highlightAnnotation) {
+//            [self setNeedsDisplayForAnnotation:highlightAnnotation];
+//            [self setHighlightAnnotation:nil];
+//        }
+    } else if ([[CPDFListView superclass] instancesRespondToSelector:_cmd]) {
+        [super draggingExited:sender];
+    }
+}
+
+- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
+    BOOL performedDrag = NO;
+    NSPasteboard *pasteboard = [sender draggingPasteboard];
+    if ([sender draggingSource] != self) {
+        NSArray* filePaths = [pasteboard propertyListForType:NSFilenamesPboardType];
+        NSArray *supportArray= [NSArray arrayWithObjects:@"jpg",@"cur",@"bmp",@"jpeg",@"gif",@"png",@"tiff",@"tif",/*@"pic",*/@"ico",@"icns",@"tga",@"psd",@"eps",@"hdr",@"jp2",@"jpc",@"pict",@"sgi",@"pdf", nil];
+        
+        NSString *filePath = filePaths.firstObject;
+        if ([supportArray containsObject:[filePath.pathExtension lowercaseString]]) {
+            if (![[IAPProductsManager defaultManager] isAvailableAllFunction]) {
+                [[KMPurchaseCompareWindowController sharedInstance] showWindow:nil];
+                return NO;
+            }
+            if([[filePath.pathExtension lowercaseString] isEqual:@"pdf"]) {
+                PDFDocument *document = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:filePath]];
+                if([document isLocked]) {
+                    return NO;
+                }
+            }
+            NSImage *image = [[NSImage alloc] initWithContentsOfFile:filePath];
+            
+            NSPoint point =  [sender draggingLocation];
+            point = [self convertPoint:point fromView:nil];
+            CPDFPage *page = [self pageForPoint:point nearest:YES];
+            NSRect rect = NSMakeRect(point.x, point.y - 45, 360, 90);
+            NSRect bounds = [self convertRect:rect toPage:page];
+            if (page != nil) {
+                CPDFListStampAnnotation *newAnnotation = [[CPDFListStampAnnotation alloc] initWithDocument:self.document image:image];
+                newAnnotation.bounds = bounds;
+                [newAnnotation setBorderBoundsWithImage:image];
+                
+                [self addAnnotation:newAnnotation toPage:page];
+                [[self undoManager] setActionName:NSLocalizedString(@"Add Note", @"Undo action name")];
+                
+                [self updateActiveAnnotations:@[newAnnotation]];
+                [self setNeedsDisplayAnnotation:newAnnotation];
+            }
+            return YES;
+        }
+    }
+    return NO;
+}
+
 #pragma mark - NSPopoverDelegate
 
 - (void)popoverWillClose:(NSNotification *)notification {

+ 7 - 7
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/EditPDF/KMEditImagePropertyViewController.swift

@@ -243,13 +243,13 @@ class KMEditImagePropertyViewController: NSViewController {
         cropVC?.action = #selector(cutImageAction)
         cropVC?.button(type: .Sec, size: .m)
         cropVC?.stringValue = NSLocalizedString("Crop", comment: "")
-//        cropVC?.borderColor = KMAppearance.Interactive.s0Color()
-//        cropVC?.background = KMAppearance.Layout.l1Color()
-//        cropVC?.background_hov = KMAppearance.Layout.l1Color()
-//        cropVC?.background_focus = KMAppearance.Layout.l1Color()
-//        cropVC?.textColor = KMAppearance.Layout.h1Color()
-//        cropVC?.textColor_hov = KMAppearance.Layout.h1Color()
-//        cropVC?.textColor_focus = KMAppearance.Layout.h1Color()
+        cropVC?.borderColor = KMAppearance.Interactive.s0Color()
+        cropVC?.background = KMAppearance.Layout.l1Color()
+        cropVC?.background_hov = KMAppearance.Layout.l1Color()
+        cropVC?.background_focus = KMAppearance.Layout.l1Color()
+        cropVC?.textColor = KMAppearance.Layout.h1Color()
+        cropVC?.textColor_hov = KMAppearance.Layout.h1Color()
+        cropVC?.textColor_focus = KMAppearance.Layout.h1Color()
         cropVC?.updateUI()
         
         

+ 4 - 4
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseCompareDMGWindowController.m

@@ -460,8 +460,8 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     }
     [self.buyNowButton setTitleColor:[NSColor whiteColor]];
     
-    if (KMAdvertisementManager.manager.info.discountRecommond.content.count > 0) {
-        KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountRecommond.content.firstObject;
+    if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
+        KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
         if ([info.show isEqual:@"true"] ) {
             self.discountTipImage.hidden = NO;
             
@@ -650,8 +650,8 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 
 - (void)recommondInfoUpdateNoti:(NSNotification *)noti {
     dispatch_async(dispatch_get_main_queue(), ^{
-        if (KMAdvertisementManager.manager.info.discountRecommond.content.count > 0) {
-            KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountRecommond.content.firstObject;
+        if (KMAdvertisementManager.manager.info.discountContent.content.count > 0) {
+            KMAdvertisementItemInfo *info = KMAdvertisementManager.manager.info.discountContent.content.firstObject;
             if ([info.show isEqual:@"true"] ) {
                 self.discountTipImage.hidden = NO;
                 self.discountTipImage.image = info.image;