KMEnumExtensions.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // KMEnumExtensions.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by tangchao on 2023/7/14.
  6. //
  7. import Foundation
  8. protocol KMSubscribeWaterMarkTypeConvertProtocol {
  9. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType
  10. }
  11. extension KMToolbarType: KMSubscribeWaterMarkTypeConvertProtocol {
  12. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  13. switch self {
  14. case .word:
  15. return .toWord
  16. case .excel:
  17. return .toExcel
  18. case .ppt:
  19. return .toPPT
  20. case .rtf:
  21. return .toRTF
  22. case .csv:
  23. return .toCSV
  24. case .html:
  25. return .toHTML
  26. case .conversion_text:
  27. return .toText
  28. case .conversion_image:
  29. return .toImage
  30. case .compress:
  31. return .compress
  32. case .merge:
  33. return .merge
  34. default:
  35. return .none
  36. }
  37. }
  38. }
  39. extension KMPDFConvertType: KMSubscribeWaterMarkTypeConvertProtocol {
  40. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  41. switch self {
  42. case .word:
  43. return .toWord
  44. case .excel:
  45. return .toExcel
  46. case .ppt:
  47. return .toPPT
  48. case .rtf:
  49. return .toRTF
  50. case .csv:
  51. return .toCSV
  52. case .html:
  53. return .toHTML
  54. case .text:
  55. return .toText
  56. case .image:
  57. return .toImage
  58. default:
  59. return .none
  60. }
  61. }
  62. }
  63. extension KMItemKey: KMSubscribeWaterMarkTypeConvertProtocol {
  64. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  65. switch self {
  66. case .leftRotate:
  67. return .rotate
  68. case .rightRotate:
  69. return .rotate
  70. case .paste:
  71. return .copy
  72. case .delete:
  73. return .delete
  74. default:
  75. return .none
  76. }
  77. }
  78. }
  79. extension KMPageEditType: KMSubscribeWaterMarkTypeConvertProtocol {
  80. func toSubscribeWaterMarkType() -> KMSubscribeWaterMarkType {
  81. switch self {
  82. case .leftRotate:
  83. return .rotate
  84. case .rightRotate:
  85. return .rotate
  86. case .insert:
  87. return .insert
  88. case .extract:
  89. return .extract
  90. case .replace:
  91. return .replace
  92. case .split:
  93. return .split
  94. case .reverse:
  95. return .none
  96. case .delete:
  97. return .delete
  98. case .paste:
  99. return .copy
  100. default:
  101. return .none
  102. }
  103. }
  104. }