浏览代码

综合-合并处理高保真

tangchao 1 年之前
父节点
当前提交
239f753fbf

二进制
PDF Office/PDF Office.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile.xcuserdatad/UserInterfaceState.xcuserstate


+ 1 - 1
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendWindow.h

@@ -25,7 +25,7 @@ typedef NS_OPTIONS(NSUInteger, KMPDFPageEditType) {
 @property (nonatomic,copy) void (^saveAsPDFFilePath) (NSString *filePath);
 
 - (id)initWithFilePaths:(NSArray *)files;
-- (id)initWithPDFDocument:(PDFDocument *)document;
+- (id)initWithPDFDocument:(PDFDocument *)document password:(NSString *)password;
 
 - (void)beginSheetModalForWindow:(NSWindow *)window completionHandler:(void (^)(BOOL isSuccessfully ,NSIndexSet * selectedIndexSet))handler;
 

+ 15 - 4
PDF Office/PDF Office/Class/Merge/OCPart/KMPDFEditAppendWindow.m

@@ -201,19 +201,30 @@ static NSString * const KMTableColumnSizeID = @"size";
         self.addFiles = files;
         self.editType = KMPDFPageEditMerge;
         _lockFilePathArr = [[NSMutableArray alloc] init];
+        _files = [[NSMutableArray alloc] init];
 
     }
     return self;
 }
 
-- (id)initWithPDFDocument:(PDFDocument *)document
+- (id)initWithPDFDocument:(PDFDocument *)document password:(NSString *)password
 {
     if (self = [super initWithWindowNibName:@"KMPDFEditAppendWindow"]) {
         
-        self.PDFDocument = document;
+//        self.PDFDocument = document;
+        self.PDFDocument = [[PDFDocument alloc] init];
         self.editType = KMPDFPageEditAppend;
         _lockFilePathArr = [[NSMutableArray alloc] init];
-
+        _files = [[NSMutableArray alloc] init];
+
+        KMFileAttribute *file = [[KMFileAttribute alloc] init];
+        file.myPDFDocument = document;
+        file.filePath = document.documentURL.path;
+        if (password && password.length > 0) {
+            file.password = password;
+            file.isLocked = YES;
+        }
+        [self.files addObject:file];
     }
     return self;
 }
@@ -322,7 +333,7 @@ static NSString * const KMTableColumnSizeID = @"size";
     self.tableView.rowHeight = 76;
     
     _insertIndexSet = [[NSMutableIndexSet alloc] init];
-    _files = [[NSMutableArray alloc] init];
+    
     [self addFiles:_addFiles];
     
     [_progress setHidden:YES];

+ 2 - 1
PDF Office/PDF Office/Class/PDFTools/Compress/Controller/KMCompressWindowController.swift

@@ -208,7 +208,8 @@ class KMCompressWindowController: NSWindowController {
         }
         
         NSPanel.savePanel(self.window!, true) { panel in
-            panel.nameFieldStringValue = "[New File]"+self.documentURL.lastPathComponent
+            panel.nameFieldStringValue = "[New File]"+self.documentURL.deletingPathExtension().lastPathComponent
+            panel.allowedFileTypes = ["pdf"]
         } completion: { response, url, isOpen in
             if (response == .cancel) {
                 return

+ 3 - 2
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -1528,9 +1528,10 @@ extension KMMainViewController : KMMainToolbarControllerDelegate {
         }
         
         if (type == .merge) { /// 合并
+            self.saveDocument()
             let document = PDFDocument(url: self.listView.document.documentURL)
-            let windowController = KMPDFEditAppendWindow(pdfDocument: document)
-            windowController?.beginSheetModal(for: self.view.window, completionHandler: { [weak self] result, selectedIndexSet in
+            let windowController = KMPDFEditAppendWindow(pdfDocument: document, password: self.listView.document.password)
+            windowController?.beginSheetModal(for: self.view.window, completionHandler: { result, selectedIndexSet in
 
             })
             return

+ 11 - 0
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController.swift

@@ -496,6 +496,17 @@ import Cocoa
         }
     }
     
+    // MARK: -
+    // MARK: 保存文档
+    public func saveDocument() {
+        let document: KMMainDocument? = self.browserWindowController?.document as? KMMainDocument
+        if (document?.isDocumentEdited == nil || document!.isDocumentEdited == false) {
+            return
+        }
+        
+        document?.save(nil)
+    }
+    
     //MARK: - PDFListViewDelegate
     func pdfViewDocumentDidLoaded(_ pdfView: CPDFView!) {
 #if DEBUG