KMConvertExcelWindowController.swift 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // KMConvertExcelWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2022/12/6.
  6. //
  7. import Cocoa
  8. // 转档 Excel 窗口
  9. class KMConvertExcelWindowController: KMConvertBaseWindowController {
  10. override var fileExtension: String {
  11. return KMPDFConvert.pathExtension(.excel)
  12. }
  13. override func initDefaultValue() {
  14. super.initDefaultValue()
  15. self.titleLabel.stringValue = NSLocalizedString("PDF to Excel", comment: "")
  16. }
  17. override func initSubViews() {
  18. super.initSubViews()
  19. self.refreshUI()
  20. }
  21. override func initSettingView() -> KMConvertSettingView? {
  22. return KMConvertExcelSettingView.createFromNib()
  23. }
  24. override func initConvert() -> KMPDFConvert {
  25. return KMPDFConvertExcel()
  26. }
  27. override func refreshUI() {
  28. super.refreshUI()
  29. Task { @MainActor in
  30. if await (KMLightMemberManager.manager.canPayFunction() == false) {
  31. self.setupContentHeight(height: 391+20, animated: true)
  32. return
  33. }
  34. self.setupContentHeight(height: 391)
  35. }
  36. }
  37. override func convertModelAppendParams(convert: KMPDFConvert) {
  38. super.convertModelAppendParams(convert: convert)
  39. let settingView: KMConvertExcelSettingView = self.settingView as! KMConvertExcelSettingView
  40. if settingView.selectedSettingIndex == 0 {
  41. convert.isExtractTable = false
  42. convert.isExtractText = false
  43. if (settingView.selectedSheetIndex == 0) {
  44. convert.isAllInOneSheet = false
  45. } else if (settingView.selectedSheetIndex == 1) {
  46. convert.isAllInOneSheet = true
  47. }
  48. } else if settingView.selectedSettingIndex == 1 {
  49. convert.isAllInOneSheet = false
  50. convert.isExtractText = false
  51. convert.isExtractTable = true
  52. convert.extractTableIndex = settingView.selectedTableFormatIndex
  53. } else if (settingView.selectedSettingIndex == 2) {
  54. convert.isAllInOneSheet = false
  55. convert.isExtractTable = false
  56. convert.isExtractText = true
  57. }
  58. }
  59. }