KMEnumExtensions.swift 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. //
  2. // KMEnumExtensions.swift
  3. // PDF Master
  4. //
  5. // Created by tangchao on 2023/7/14.
  6. //
  7. import Foundation
  8. protocol KMSubscribeWaterMarkTypeConvertProtocol {
  9. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType
  10. }
  11. /*
  12. @objc enum KMToolbarType: Int {
  13. /// conversion
  14. case word = 3000
  15. case excel = 3001
  16. case ppt = 3002
  17. case rtf = 3003
  18. case csv = 3004
  19. case html = 3005
  20. case conversion_text = 3006
  21. case conversion_image = 3007
  22. /// tool
  23. case compress = 8000
  24. case merge = 8001
  25. case fileCompare = 8002
  26. case secure = 8003
  27. case redact = 8004
  28. case watermark = 8005
  29. case background = 8006
  30. case headerAndFooter = 8007
  31. case bates = 8008
  32. case crop = 8009
  33. }
  34. */
  35. extension KMToolbarType: KMSubscribeWaterMarkTypeConvertProtocol {
  36. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  37. switch self {
  38. case .word:
  39. return .toWord
  40. case .excel:
  41. return .toExcel
  42. case .ppt:
  43. return .toPPT
  44. case .rtf:
  45. return .toRTF
  46. case .csv:
  47. return .toCSV
  48. case .html:
  49. return .toHTML
  50. case .conversion_text:
  51. return .toText
  52. case .conversion_image:
  53. return .toImage
  54. case .compress:
  55. return .compress
  56. case .merge:
  57. return .merge
  58. default:
  59. return .none
  60. }
  61. }
  62. }
  63. /*
  64. enum KMPDFConvertType: Int {
  65. case word = 0
  66. case excel = 1
  67. case ppt = 2
  68. case rtf = 3
  69. case csv = 4
  70. case html = 5
  71. case text = 6
  72. case jpeg = 7
  73. case jpg = 8
  74. case png = 9
  75. case gif = 10
  76. case tiff = 11
  77. case tga = 12
  78. case bmp = 13
  79. case jp2 = 14
  80. static let image: KMPDFConvertType = .jpeg
  81. }
  82. */
  83. extension KMPDFConvertType: KMSubscribeWaterMarkTypeConvertProtocol {
  84. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  85. switch self {
  86. case .word:
  87. return .toWord
  88. case .excel:
  89. return .toExcel
  90. case .ppt:
  91. return .toPPT
  92. case .rtf:
  93. return .toRTF
  94. case .csv:
  95. return .toCSV
  96. case .html:
  97. return .toHTML
  98. case .text:
  99. return .toText
  100. case .image:
  101. return .toImage
  102. default:
  103. return .none
  104. }
  105. }
  106. }
  107. /*
  108. @objc enum KMItemKey: Int {
  109. case print = 0 // 打印
  110. case delete
  111. case leftRotate
  112. case rightRotate
  113. case cut
  114. case paste
  115. }
  116. */
  117. extension KMItemKey: KMSubscribeWaterMarkTypeConvertProtocol {
  118. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  119. switch self {
  120. case .leftRotate:
  121. return .rotate
  122. case .rightRotate:
  123. return .rotate
  124. case .paste:
  125. return .copy
  126. case .delete:
  127. return .delete
  128. default:
  129. return .none
  130. }
  131. }
  132. }
  133. /*
  134. enum KMPageEditType: Int {
  135. case pageRange = 1
  136. case leftRotate
  137. case rightRotate
  138. case insert
  139. case extract
  140. case replace
  141. case split
  142. case reverse
  143. case delete
  144. case zoomOut
  145. case zoomIn
  146. static let none: KMPageEditType = KMPageEditType(rawValue: 0)!
  147. static var insert_files: Int {
  148. get {
  149. return self.insert.rawValue + 1000
  150. }
  151. }
  152. static var insert_blank_page: Int {
  153. get {
  154. return self.insert.rawValue + 1001
  155. }
  156. }
  157. static var insert_custom_page: Int {
  158. get {
  159. return self.insert.rawValue + 1002
  160. }
  161. }
  162. }
  163. */
  164. extension KMPageEditType: KMSubscribeWaterMarkTypeConvertProtocol {
  165. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  166. switch self {
  167. case .leftRotate:
  168. return .rotate
  169. case .rightRotate:
  170. return .rotate
  171. case .insert:
  172. return .insert
  173. case .extract:
  174. return .extract
  175. case .replace:
  176. return .replace
  177. case .split:
  178. return .split
  179. case .reverse:
  180. return .none
  181. case .delete:
  182. return .delete
  183. case .paste:
  184. return .copy
  185. default:
  186. return .none
  187. }
  188. }
  189. }