// // KMOCRModel.swift // PDF Master // // Created by lizhe on 2022/12/7. // import Cocoa /** OCR导出类型 */ struct KMOCRExportOptions: OptionSet { let rawValue: Int static let pdf = KMOCRExportOptions(rawValue: 1 << 0) static let txt = KMOCRExportOptions(rawValue: 1 << 1) static let all: KMOCRExportOptions = [.pdf, .txt] } /** OCR语言类型 */ enum KMOCRLanguageType: String, CaseIterable { case auto case english = "en-US" case french = "fr-FR" case italian = "it-IT" case german = "de-DE" case spanish = "es-ES" case portuguese = "pt-BR" case chineseTraditional = "zh-Hant" case chineseSimplified = "zh-Hans" static func allValues() -> [String] { var array: [String] = [] for key in KMOCRLanguageType.allCases { array.append(key.rawValue) } return array } static func typeOfRawValue(_ rawValue: String) -> KMOCRLanguageType { var type: KMOCRLanguageType = .english switch rawValue { case KMOCRLanguageType.english.rawValue: type = .english case KMOCRLanguageType.french.rawValue: type = .french case KMOCRLanguageType.italian.rawValue: type = .italian case KMOCRLanguageType.german.rawValue: type = .german case KMOCRLanguageType.spanish.rawValue: type = .spanish case KMOCRLanguageType.portuguese.rawValue: type = .portuguese case KMOCRLanguageType.chineseTraditional.rawValue: type = .chineseTraditional case KMOCRLanguageType.chineseSimplified.rawValue: type = .chineseSimplified default: type = .english } return type } } class KMOCRModel: NSObject { var filePaths: Array? var exportOptions: KMOCRExportOptions! = .pdf var languageType: KMOCRLanguageType! = .english var exportFilePath: String = "" var languageDic: NSDictionary = [KMGOCRLanguageCodeKey:"en-US", KMGOCRLanguageStringKey:"English"] static func supportedTypes() -> [String] { return ["pdf"] } }