Explorar el Código

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

liujiajie hace 6 meses
padre
commit
14e1457abb

+ 2 - 1
PDF Office/PDF Master/Class/Document/KMMainDocument.swift

@@ -592,7 +592,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
             
             let dic = notification.object as? NSDictionary
             if dic?["object"] is CPDFAnnotation {
-                let annotation : CPDFAnnotation = dic?["object"] as? CPDFAnnotation ?? CPDFAnnotation()
+                guard let annotation = dic?["object"] as? CPDFAnnotation else { return }
                 document = annotation.page.document
 
             } else if dic?["object"] is CPDFListView {
@@ -817,6 +817,7 @@ typealias KMMainDocumentCloudUploadHanddler = (@escaping(Bool, String)->()) -> (
         self.mainViewController?.removeOwnerPassword()
     }
     @IBAction func printPDFDocument(_ sender: Any?) {
+        self.mainViewController?.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.mainViewController?.document, inputPageRange: KMPrintPageRange())
     }
     @IBAction func performFindPanelAction(_ sender: Any?) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Print/KMPrintWindowController.swift

@@ -375,7 +375,7 @@ extension KMPrintWindowController {
             let controller = KMPrintAccessoryController_OC(nibName: "KMPrintAccessoryController_OC", bundle: nil)
             printOperation.printPanel.addAccessoryController(controller)
             
-            printOperation.runModal(for: NSApplication.shared.mainWindow!, delegate: self, didRun: nil, contextInfo: nil)
+            printOperation.runModal(for: NSWindow.currentWindow(), delegate: self, didRun: nil, contextInfo: nil)
         }
     }
     

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

@@ -4909,10 +4909,10 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
     }];
 }
 
-- (void)menuItemClick_StampExport: (NSMenuItem *)sender{
+- (void)menuItemClick_StampExport: (NSMenuItem *)sender {
+    NSImage *image = nil;
     if ([self.activeAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
         CPDFStampAnnotation *annotation = (CPDFStampAnnotation *)self.activeAnnotation;
-        NSImage *image = nil;
         if ([self.activeAnnotation isKindOfClass:[KMAnnotationStamp class]]) {
             image = annotation.stampImage;
         }
@@ -4928,6 +4928,11 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationDefault];
             [image unlockFocus];
         }
+    } else if (self.currentSelection.selectionType == CPDFSelectionTypeImage) {
+        image = [self.document extractImageFromPage:self.currentSelection.page imageSelection:self.currentSelection];
+    }
+    
+    if (image) {
         NSData *data = [image TIFFRepresentation];
         NSBitmapImageRep *imageRep = [NSBitmapImageRep imageRepWithData:data];
         [imageRep setSize:[image size]];

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -2996,6 +2996,7 @@ extension KMMainViewController {
     }
     
     internal func showPrintWindow(pageRange: KMPrintPageRange = KMPrintPageRange(type: .allPage, selectPages: [])) {
+        self.saveDocument()
         if (self.listView.document != nil && !self.listView.document.allowsPrinting) { // 有打印限制
             KMPasswordInputWindow.openWindow(window: self.view.window!, type: .owner,  url: self.listView.document.documentURL) { [weak self] result ,password in
                 if (result == .cancel) {

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

@@ -1130,14 +1130,17 @@ extension KMMainViewController: KMSystemToolMenuProtocol {
     }
     
     func togglePoster(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .poster)
     }
     
     func toggleMultiple(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .multipage)
     }
     
     func toggleBooklet(_ sender: Any?) {
+        self.saveDocument()
         KMPrintWindowController.showNewPrintWindowControll(inputDocument: self.listView.document, inputPageRange: KMPrintPageRange(), printType: .pamphlet)
     }