KMMergeWindowController.swift 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. //
  2. // KMMergeWindowController.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2023/11/8.
  6. //
  7. import Cocoa
  8. typealias KMMergeWindowControllerCancelAction = (_ controller: KMMergeWindowController) -> Void
  9. typealias KMMergeWindowControllerAddFilesAction = (_ controller: KMMergeWindowController) -> Void
  10. typealias KMMergeWindowControllerMergeAction = (_ controller: KMMergeWindowController) -> Void
  11. typealias KMMergeWindowControllerClearAction = (_ controller: KMMergeWindowController) -> Void
  12. class KMMergeWindowController: NSWindowController {
  13. @IBOutlet weak var mergeView: KMMergeView!
  14. var cancelAction: KMMergeWindowControllerCancelAction?
  15. var pdfDocument: PDFDocument = PDFDocument()
  16. var password: String = ""
  17. var oriDucumentUrl: URL?
  18. // - (id)initWithPDFDocument:(PDFDocument *)document password:(NSString *)password
  19. // {
  20. // if (self = [super initWithWindowNibName:@"KMPDFEditAppendWindow"]) {
  21. //
  22. // // self.PDFDocument = document;
  23. // self.PDFDocument = [[PDFDocument alloc] init];
  24. // self.editType = KMPDFPageEditAppend;
  25. // _lockFilePathArr = [[NSMutableArray alloc] init];
  26. // _files = [[NSMutableArray alloc] init];
  27. //
  28. // KMFileAttribute *file = [[KMFileAttribute alloc] init];
  29. // file.myPDFDocument = document;
  30. // file.filePath = document.documentURL.path;
  31. // file.oriFilePath = self.oriDucumentUrl.path;
  32. // if (password && password.length > 0) {
  33. // file.password = password;
  34. // file.isLocked = YES;
  35. // }
  36. // [self.files addObject:file];
  37. // }
  38. // return self;
  39. // }
  40. convenience init(document: PDFDocument, password: String) {
  41. self.init(windowNibName: "KMMergeWindowController")
  42. }
  43. override func windowDidLoad() {
  44. super.windowDidLoad()
  45. self.window!.title = NSLocalizedString("Merge PDF Files", comment: "");
  46. // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
  47. mergeView.addFilesAction = { [unowned self] view in
  48. }
  49. mergeView.clearAction = { [unowned self] view in
  50. }
  51. mergeView.mergeAction = { [unowned self] view in
  52. }
  53. mergeView.cancelAction = { [unowned self] view in
  54. cancelAction?(self)
  55. }
  56. }
  57. }