Bladeren bron

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

tangchao 1 jaar geleden
bovenliggende
commit
896ffb9368

+ 74 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -4086,6 +4086,80 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         [self.activeAnnotations addObject:annotation];
     }
     [[NSFontManager sharedFontManager] orderFrontFontPanel:sender];
+    [[NSFontManager sharedFontManager] setTarget:self];
+    [[NSFontManager sharedFontManager] setAction:@selector(changeFontPanel:)];
+//    [[NSFontManager sharedFontManager] orderFrontFontPanel:self];
+}
+
+- (void)changeFontPanel:(id)sender {
+    for (CPDFAnnotation *tAnnotation in self.activeAnnotations) {
+        if ([tAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
+            NSFont *font = [NSFont fontWithName:tAnnotation.fontName size:tAnnotation.fontSize];
+            NSFont *newfont = [sender convertFont:font];
+            if (newfont) {
+                ((CPDFFreeTextAnnotation *)tAnnotation).font = newfont;
+            }
+        }
+    }
+    [self updateAnnotation];
+    [self adjustFreeText];
+}
+
+- (void)updateAnnotation {
+    if ([self.activeAnnotation isKindOfClass:[CPDFFreeTextAnnotation class]]) {
+        CPDFFreeTextAnnotation *textNote = (CPDFFreeTextAnnotation *)self.activeAnnotation;
+        BOOL isEdit = [self isEditWithCurrentFreeText:textNote];
+        if (isEdit) {
+            [self commitEditAnnotationFreeText:textNote];
+        }
+        [self setNeedsDisplayAnnotation:self.activeAnnotation];
+    }
+    for (CPDFAnnotation *tAnnotation in self.activeAnnotations) {
+        if ([tAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
+            [(KMSelfSignAnnotation *)tAnnotation updateAppearanceStream];
+        }
+        if ([tAnnotation isKindOfClass:[CPDFMarkupAnnotation class]]) {
+            [self setNeedsDisplayForPage:tAnnotation.page];
+        } else {
+            [self setNeedsDisplayAnnotationViewForPage:tAnnotation.page];
+        }
+    }
+}
+
+-(void)adjustFreeText {
+    if (self.activeAnnotations.count > 0) {
+        for (CPDFAnnotation *an in self.activeAnnotations) {
+            if ([an isKindOfClass:[CPDFFreeTextAnnotation class]]) {
+                CPDFFreeTextAnnotation *freeTextAn = (CPDFFreeTextAnnotation *)an;
+                NSFont *font = freeTextAn.font;
+                NSMutableDictionary *attributes = [NSMutableDictionary dictionary];
+                attributes[NSFontAttributeName] = font;
+                NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
+                style.alignment = freeTextAn.alignment;
+                attributes[NSParagraphStyleAttributeName] = style;
+                
+                NSString *contents = freeTextAn.contents ?: @"";
+                CGSize textViewSize = [contents boundingRectWithSize:CGSizeMake(freeTextAn.bounds.size.width, MAXFLOAT)
+                                                             options:NSStringDrawingUsesLineFragmentOrigin
+                                                          attributes:attributes
+                                                             context:nil].size;
+                
+                CGRect rect = freeTextAn.bounds;
+                
+                if (textViewSize.height != freeTextAn.bounds.size.height) {
+                    rect.origin.y -= (textViewSize.height - rect.size.height);
+                    rect.size.height = textViewSize.height;
+                }
+                
+                if (textViewSize.width < freeTextAn.bounds.size.width) {
+                    rect.size.width = textViewSize.width;
+                }
+                
+                freeTextAn.bounds = rect;
+            }
+        }
+        
+    }
 }
 
 - (void)PreviousPageAction:(NSMenuItem *)item{

+ 82 - 31
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -3545,16 +3545,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
         
         Task { @MainActor in
             if (type == .compress) { /// 压缩
-//                #if VERSION_DMG
-//                if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-//                    let _ = KMComparativeTableViewController.show(window: self.view.window!, .compress)
-                    
-//                    self.toolbarController.cancelSelected(KMToolbarToolCompressItemIdentifier)
-//                    return
-                    
-//                }
-//                #endif
-
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
                 if await (KMLightMemberManager.manager.canPayFunction() == false) {
 //                    self.view.window?.contentView?.superview?.beginLoading()
                     let document = self.listView.document
@@ -3638,14 +3634,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             }
             
             if (type == .merge) { /// 合并
-//                #if VERSION_DMG
-//                if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-//                    let _ = KMComparativeTableViewController.show(window: self.view.window!, .merge)
-//                    
-//                    self.toolbarController.cancelSelected(KMToolbarToolMergeItemIdentifier)
-//                    return
-//                }
-//                #endif
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
 
                 if (self.listView.document.allowsCopying == false || self.listView.document.allowsPrinting == false) {
                     if await (KMLightMemberManager.manager.canPayFunction() == false) {
@@ -3699,12 +3693,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             }
             
             if (type == .crop) {
-                #if VERSION_DMG
-                if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-                    let _ = KMComparativeTableViewController.show(window: self.view.window!, .crop)
-                    return
-                }
-                #endif
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
 
                 self.recordSaveWatermarkFlag(type: .crop)
                 
@@ -3721,6 +3715,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 //            self.cropCustomArea()
             } else if (type == .bates || type == .headerAndFooter) {
                 if (index == 1) {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     var windowController: KMBaseWindowController = KMBaseWindowController()
                     
                     if (type == .bates) {
@@ -3780,6 +3781,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                         self.showBatchWindow(type: .RemoveHeaderFooter, files: [file])
                     }
                 } else if (index == 2) { //// 移除
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     if type == .headerAndFooter {
                         let savePanelAccessoryViewController = KMSavePanelAccessoryController()
                         let savePanel = NSSavePanel()
@@ -3864,6 +3872,14 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     self.openRightPane()
                 }
             } else if (type == .redact) { /// 标记密文
+                
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                
                 if (index == 1) { /// 取消
                     if (self.hasAddRedact) {
                         let alert = NSAlert()
@@ -3947,12 +3963,12 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
             } else if (type == .secure) { /// 安全
-                #if VERSION_DMG
-                if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
-                    let _ = KMComparativeTableViewController.show(window: self.view.window!, .secure)
-                    return
-                }
-                #endif
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
                 
                 if (index == 1) { /// 设置密码
                     if (!self.listView.document!.allowsCopying || !self.listView.document!.allowsPrinting) {
@@ -4048,6 +4064,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     return
                 }
             } else if type == .comparison {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                
                 let controller = KMCompareWindowController(windowNibName: "KMCompareWindowController")
                 self.currentWindowController = controller
                 controller.password = self.document?.password ?? ""
@@ -4083,6 +4106,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 await NSWindow.currentWindow().beginSheet(controller.window!)
             } else if type == .watermark {
                 if index == 1 {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     let controller = KMWatermarkWindowController(windowNibName: "KMWatermarkWindowController")
                     self.currentWindowController = controller
                     controller.pdfDocument = self.document
@@ -4100,6 +4130,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
 //                    NSWindow.currentWindow().beginSheet(controller.window!)
                     NSWindow.currentWindow().beginSheet(controller.window!, completionHandler: nil)
                 } else if index == 2 {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     let watermarks = self.listView.document.watermarks()
                     if (watermarks == nil || watermarks!.count <= 0) {
                         let alert = NSAlert()
@@ -4156,6 +4193,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                 }
             } else if type == .background {
                 if index == 1 {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     let controller = KMBackgroundWindowController(windowNibName: "KMBackgroundWindowController")
                     self.currentWindowController = controller
                     controller.pdfDocument = self.document
@@ -4173,6 +4217,13 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
                     
                     await NSWindow.currentWindow().beginSheet(controller.window!)
                 } else if index == 2 {
+#if VERSION_FREE
+        if !IAPProductsManager.default().isAvailableAllFunction() {
+            KMPurchaseCompareWindowController.sharedInstance().showWindow(nil)
+            return
+        }
+#endif
+                    
                     guard let document = self.document else { return }
                     
                     if !document.allowsPrinting || !document.allowsCopying {
@@ -4221,7 +4272,7 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
             }
         }
     }
-    
+
     func showBatchWindow(type: KMBatchOperationType, files: [KMFileAttribute]?) {
         let batchWindowController = KMBatchOperateWindowController.sharedWindowController
                 batchWindowController.window?.makeKeyAndOrderFront("")