|
@@ -171,6 +171,85 @@ extension KMHomeViewController {
|
|
break
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ func showConvertWindow(type: KMPDFConvertType) {
|
|
|
|
+ Task { @MainActor in
|
|
|
|
+ if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
|
|
|
|
+ let _ = KMComparativeTableViewController.show(window: self.view.window!, .convert)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if await (KMLightMemberManager.manager.canPayFunction() == false) {
|
|
|
|
+ let _ = KMSubscribeWaterMarkWindowController.show(window: self.view.window!) { isSubscribeSuccess, isWaterMarkExport, isClose in
|
|
|
|
+ if (isClose) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self.km_secure_openPanel_convert(type: type)
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.km_secure_openPanel_convert(type: type)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ func km_secure_openPanel_convert(type: KMPDFConvertType) {
|
|
|
|
+ DispatchQueue.main.async {
|
|
|
|
+ NSOpenPanel.km_secure_openPanel_success(window: self.view.window!) { url, password in
|
|
|
|
+ if (url.path.isPDFValid() == false) {
|
|
|
|
+ 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
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self._showConvertWindow(type: type, url: url, password: password)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // MARK: - Private Methods
|
|
|
|
+
|
|
|
|
+ fileprivate func _showConvertWindow(type: KMPDFConvertType, url: URL, password: String? = nil) {
|
|
|
|
+ var windowController: KMConvertBaseWindowController?
|
|
|
|
+ if (type == .word) { /// Word
|
|
|
|
+ windowController = KMConvertWordWindowController()
|
|
|
|
+ } else if (type == .excel) {
|
|
|
|
+ windowController = KMConvertExcelWindowController()
|
|
|
|
+ } else if (type == .ppt || type == .rtf || type == .html || type == .text) {
|
|
|
|
+ windowController = KMConvertPPTsWindowController()
|
|
|
|
+ if (type == .ppt) {
|
|
|
|
+ windowController?.subType = 1
|
|
|
|
+ } else if (type == .rtf) {
|
|
|
|
+ windowController?.subType = 2
|
|
|
|
+ } else if (type == .html) {
|
|
|
|
+ windowController?.subType = 3
|
|
|
|
+ } else if (type == .text) {
|
|
|
|
+ windowController?.subType = 4
|
|
|
|
+ }
|
|
|
|
+ } else if (type == .csv) {
|
|
|
|
+ windowController = KMConvertCSVWindowController()
|
|
|
|
+ } else if (type == .image) {
|
|
|
|
+ windowController = KMConvertImageWindowController()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ let model = KMDocumentModel(url: url)
|
|
|
|
+ if (password != nil) {
|
|
|
|
+ let _ = model.unlock(password!)
|
|
|
|
+ }
|
|
|
|
+ windowController?.documentModel = model
|
|
|
|
+
|
|
|
|
+ windowController?.itemClick = { [weak self] index in
|
|
|
|
+ if (self?.currentWindowController == nil) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ self?.view.window?.endSheet((self?.currentWindowController?.window)!)
|
|
|
|
+ self?.currentWindowController = nil
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ self.view.window?.beginSheet((windowController?.window)!)
|
|
|
|
+ self.currentWindowController = windowController
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
// MARK: - NSSplitViewDelegate
|
|
// MARK: - NSSplitViewDelegate
|