|
@@ -616,6 +616,56 @@ extension KMHomeViewController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ internal func showConvertWindow(type: KMPDFConvertType) {
|
|
|
+ Task { @MainActor in
|
|
|
+ if await (KMLightMemberManager.manager.canUseAdvanced() == false) {
|
|
|
+ let _ = KMComparativeTableViewController.show(window: self.view.window!)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ NSOpenPanel.km_secure_openPanel_success(window: self.view.window!) { url, password in
|
|
|
+ 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: PDF Tools
|
|
|
|
|
|
// 插入
|
|
@@ -914,10 +964,10 @@ extension KMHomeViewController {
|
|
|
windowController.documentModel = model
|
|
|
|
|
|
windowController.itemClick = { [weak self] (index: Int) in
|
|
|
- if (self!.currentWindowController == nil) {
|
|
|
+ if (self?.currentWindowController == nil) {
|
|
|
return
|
|
|
}
|
|
|
- self!.view.window?.endSheet(self!.currentWindowController!.window!)
|
|
|
+ self?.view.window?.endSheet((self?.currentWindowController?.window)!)
|
|
|
self?.currentWindowController = nil
|
|
|
}
|
|
|
|
|
@@ -943,10 +993,10 @@ extension KMHomeViewController {
|
|
|
windowController.documentModel = model
|
|
|
|
|
|
windowController.itemClick = { [weak self] (index: Int) in
|
|
|
- if (self!.currentWindowController == nil) {
|
|
|
+ if (self?.currentWindowController == nil) {
|
|
|
return
|
|
|
}
|
|
|
- self!.view.window?.endSheet(self!.currentWindowController!.window!)
|
|
|
+ self?.view.window?.endSheet((self?.currentWindowController?.window)!)
|
|
|
self?.currentWindowController = nil
|
|
|
}
|
|
|
|
|
@@ -972,10 +1022,10 @@ extension KMHomeViewController {
|
|
|
windowController.documentModel = model
|
|
|
|
|
|
windowController.itemClick = { [weak self] (index: Int) in
|
|
|
- if (self!.currentWindowController == nil) {
|
|
|
+ if (self?.currentWindowController == nil) {
|
|
|
return
|
|
|
}
|
|
|
- self!.view.window?.endSheet(self!.currentWindowController!.window!)
|
|
|
+ self?.view.window?.endSheet((self?.currentWindowController?.window)!)
|
|
|
self?.currentWindowController = nil
|
|
|
}
|
|
|
|
|
@@ -1001,10 +1051,10 @@ extension KMHomeViewController {
|
|
|
windowController.documentModel = model
|
|
|
|
|
|
windowController.itemClick = { [weak self] (index: Int) in
|
|
|
- if (self!.currentWindowController == nil) {
|
|
|
+ if (self?.currentWindowController == nil) {
|
|
|
return
|
|
|
}
|
|
|
- self!.view.window?.endSheet(self!.currentWindowController!.window!)
|
|
|
+ self?.view.window?.endSheet((self?.currentWindowController?.window)!)
|
|
|
self?.currentWindowController = nil
|
|
|
}
|
|
|
|
|
@@ -1386,6 +1436,22 @@ extension KMHomeViewController {
|
|
|
self.fastTool_PDFToPPT()
|
|
|
}
|
|
|
|
|
|
+ @IBAction func menuItemAction_ConvertToRTF(_ sender: Any) {
|
|
|
+ self.showConvertWindow(type: .rtf)
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_ConvertToHTML(_ sender: Any) {
|
|
|
+ self.showConvertWindow(type: .html)
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_ConvertToText(_ sender: Any) {
|
|
|
+ self.showConvertWindow(type: .text)
|
|
|
+ }
|
|
|
+
|
|
|
+ @IBAction func menuItemAction_ConvertToCSV(_ sender: Any) {
|
|
|
+ self.showConvertWindow(type: .csv)
|
|
|
+ }
|
|
|
+
|
|
|
@IBAction func menuItemAction_ConvertToImage(_ sender: Any) {
|
|
|
self.fastTool_PDFToImage()
|
|
|
}
|