|
@@ -165,19 +165,8 @@ extension KMHomeViewController {
|
|
|
func openPDFButtonAction() {
|
|
|
NSPanel.km_open_pdf_multi_success(self.view.window!, panel: nil) { urls in
|
|
|
for url in urls {
|
|
|
- if !url.path.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- } else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: url, display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -200,18 +189,8 @@ extension KMHomeViewController {
|
|
|
for url in urls! {
|
|
|
let type = url.pathExtension.lowercased()
|
|
|
if (type == "pdf" || type == "PDF") {
|
|
|
- if !url.path.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- } else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: url, display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
} else if (type == "jpg") ||
|
|
|
(type == "cur") ||
|
|
@@ -394,18 +373,8 @@ extension KMHomeViewController {
|
|
|
selectDocument?.browser.window.orderFront(nil)
|
|
|
}
|
|
|
} else {
|
|
|
- if !url.path.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- } else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: url, display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
@@ -424,18 +393,8 @@ extension KMHomeViewController {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- if !url.path.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- } else {
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: url, display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: url, display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -571,18 +530,8 @@ extension KMHomeViewController {
|
|
|
} else {
|
|
|
}
|
|
|
if success {
|
|
|
- if !path.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- return
|
|
|
- }
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: path), display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -623,18 +572,8 @@ extension KMHomeViewController {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- if !savePath!.isPDFValid() {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("An error occurred while opening this document. The file is damaged and could not be repaired.", comment: "")
|
|
|
- alert.runModal()
|
|
|
- return
|
|
|
- }
|
|
|
- NSDocumentController.shared.openDocument(withContentsOf: URL(fileURLWithPath: savePath!), display: true) { document, documentWasAlreadyOpen, error in
|
|
|
- if error != nil {
|
|
|
- NSApp.presentError(error!)
|
|
|
- return
|
|
|
- }
|
|
|
+ NSDocumentController.shared.km_safe_openDocument(withContentsOf: URL(fileURLWithPath: savePath!), display: true) { _, _, _ in
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|