|
@@ -7,7 +7,7 @@
|
|
|
|
|
|
import Cocoa
|
|
|
|
|
|
-class SplitWindowController: NSWindowController {
|
|
|
+class SplitWindowController: KMBaseWindowController {
|
|
|
/*
|
|
|
@protocol SplitDelegate <NSObject>
|
|
|
@optional
|
|
@@ -72,10 +72,9 @@ class SplitWindowController: NSWindowController {
|
|
|
private var _PDFDocument: CPDFDocument?
|
|
|
|
|
|
private var _isSuccessfully = false
|
|
|
- /*
|
|
|
- //密码
|
|
|
- @property (nonatomic,retain) NSString *password;
|
|
|
- */
|
|
|
+
|
|
|
+ //密码
|
|
|
+ var password: String?
|
|
|
//分割样式
|
|
|
private var _splitType: Int = 0
|
|
|
|
|
@@ -133,7 +132,7 @@ class SplitWindowController: NSWindowController {
|
|
|
|
|
|
self.byFileText.isEditable = false
|
|
|
self.byFileStepper.isEnabled = false
|
|
|
- self.byPageStepper.isEnabled = false
|
|
|
+ self.byPageStepper.isEnabled = true
|
|
|
self.fileAttribute?.bAllPage = true
|
|
|
}
|
|
|
|
|
@@ -424,27 +423,20 @@ extension SplitWindowController {
|
|
|
|
|
|
private func _setInputRange() {
|
|
|
if let data = self._PDFDocument?.isLocked, data {
|
|
|
-// dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
-// PasswordWindowController *com = [[PasswordWindowController alloc] initWithWindowNibName:@"PasswordWindowController"];
|
|
|
-// com.fileURL = _fileURL;
|
|
|
-// [com beginSheetModalForWindow:self.window completionHandler:^(NSString *password) {
|
|
|
-// if (password) {
|
|
|
-// self.password = password;
|
|
|
-// [_PDFDocument unlockWithPassword:password];
|
|
|
-// NSInteger pageNumber = [_PDFDocument pageCount];
|
|
|
-// NSString *pdfName = [[[[_PDFDocument documentURL] path] lastPathComponent] stringByDeletingPathExtension];
|
|
|
-// _byFileStepper.maxValue = pageNumber;
|
|
|
-// _byPageStepper.maxValue = pageNumber;
|
|
|
-//
|
|
|
-// _partFileNameLabel.stringValue = [[NSString stringWithFormat:@"%@%@%@",pdfName,_separatorText.stringValue,_renameText.stringValue] stringByAppendingPathExtension:@"pdf"];
|
|
|
-// } else {
|
|
|
-// [NSApp endSheet:[self window]];
|
|
|
-// [[self window] orderOut:self];
|
|
|
-// [self release];
|
|
|
-// }
|
|
|
-// }];
|
|
|
-// [com release];
|
|
|
-// });
|
|
|
+ if let url = self._fileURL {
|
|
|
+ Self.checkPassword(url: url) { [weak self] success, pwd in
|
|
|
+ if success {
|
|
|
+ self?.password = pwd
|
|
|
+ self?._PDFDocument?.unlock(withPassword: pwd)
|
|
|
+ let pageNumber = self?._PDFDocument?.pageCount ?? 0
|
|
|
+ let pdfName = self?._PDFDocument?.documentURL.deletingPathExtension().lastPathComponent ?? ""
|
|
|
+ self?.byFileStepper.maxValue = Double(pageNumber)
|
|
|
+ self?.byPageStepper.maxValue = Double(pageNumber)
|
|
|
+
|
|
|
+ self?.partFileNameLabel.stringValue = String(format: "%@%@%@.pdf", pdfName, self?.separatorText.stringValue ?? "", self?.renameText.stringValue ?? "")
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
let pageNumber = self._PDFDocument?.pageCount ?? 0
|
|
|
let pdfName = self._PDFDocument?.documentURL.deletingPathExtension().path.lastPathComponent ?? ""
|
|
@@ -478,7 +470,7 @@ extension SplitWindowController {
|
|
|
self.byFileText.isEditable = false
|
|
|
self.byFileStepper.isEnabled = false
|
|
|
self.byPageText.isEditable = false
|
|
|
- self.byPageStepper.isEnabled = false
|
|
|
+ self.byPageStepper.isEnabled = true
|
|
|
|
|
|
if (self._splitType == 3) {
|
|
|
self.pageRangeComboBox.selectItem(at: 2)
|