PublicKey.swift 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. //
  2. // PublicKey.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by lxy on 2022/12/1.
  6. //
  7. import Foundation
  8. /// Main Tool
  9. let KMLeftControlToolbarItemIdentifier = "KMLeftControlToolbarItemIdentifier"
  10. let KMDocumentZoomViewToolbarItemIdentifier = "KMDocumentZoomViewToolbarItemIdentifier"
  11. let KMDocumentPreviousPageToolbarItemIdentifier = "KMDocumentPreviousPageToolbarItemIdentifier"
  12. let KMDocumentHomeToolbarItemIdentifier = "KMDocumentHomeToolbarItemIdentifier"
  13. let KMDocumentAnnotationToolbarItemIdentifier = "KMDocumentAnnotationToolbarItemIdentifier"
  14. let KMDocumentPageToolbarItemIdentifier = "KMDocumentPageToolbarItemIdentifier"
  15. let KMDocumentConversonToolbarItemIdentifier = "KMDocumentConversonToolbarItemIdentifier"
  16. let KMDocumentScanOCRToolbarItemIdentifier = "KMDocumentScanOCRToolbarItemIdentifier"
  17. let KMDocumentFormToolbarItemIdentifier = "KMDocumentFormToolbarItemIdentifier"
  18. let KMDocumentEditToolbarItemIdentifier = "KMDocumentPageEditToolbarItemIdentifier"
  19. let KMDocumentFillSginToolbarItemIdentifier = "KMDocumentFillSginToolbarItemIdentifier"
  20. let KMDocumentToolToolbarItemIdentifier = "KMDocumentToolToolbarItemIdentifier"
  21. let KMDocumentRedactToolbarItemIdentifier = "KMDocumentRedactToolbarItemIdentifier"
  22. let KMDocumentDigitalSignToolbarItemIdentifier = "KMDocumentDigitalSignToolbarItemIdentifier"
  23. let KMDocumentSignToolbarItemIdentifier = "KMDocumentSignToolbarItemIdentifier"
  24. let KMDocumentViewDisplayToolbarItemIdentifier = "KMDocumentViewDisplayToolbarItemIdentifier"
  25. let KMDocumentPrintToolbarItemIdentifier = "KMDocumentPrintToolbarItemIdentifier"
  26. let KMDocumentAITranslationToolbarItemIdentifier = "KMDocumentAITranslationToolbarItemIdentifier"
  27. let KMDocumentShareToolbarItemIdentifier = "KMDocumentShareToolbarItemIdentifier"
  28. let KMDocumentSearchToolbarItemIdentifier = "KMDocumentSearchToolbarItemIdentifier"
  29. let KMRightControlToolbarItemIdentifier = "KMRightControlToolbarItemIdentifier"
  30. let KMDocumentAIToolsToolbarItemIdentifier = "KMDocumentAIToolsToolbarItemIdentifier"
  31. let KMDocumentPageInputToolbarItemIdentifier = "KMDocumentPageInputToolbarItemIdentifier"
  32. let KMDocumentPreviousBackToolbarItemIdentifier = "previousBackItemIdentifier"
  33. let KMDocumentFirstLastToolbarItemIdentifier = "firstLastItemIdentifier"
  34. let KMDocumentPageIndicatorToolbarItemIdentifier = "pageIndicatorItemIdentifier"
  35. let KMDocumentPresentationToolbarItemIdentifier = "presentationItemIdentifier"
  36. let mainToolIdentifiers = [KMLeftControlToolbarItemIdentifier,
  37. KMDocumentZoomViewToolbarItemIdentifier, KMDocumentPreviousPageToolbarItemIdentifier,
  38. KMDocumentHomeToolbarItemIdentifier, KMDocumentAnnotationToolbarItemIdentifier, KMDocumentPageToolbarItemIdentifier, KMDocumentConversonToolbarItemIdentifier,KMDocumentRedactToolbarItemIdentifier,
  39. // KMDocumentAIToolsToolbarItemIdentifier,
  40. KMDocumentViewDisplayToolbarItemIdentifier,KMDocumentScanOCRToolbarItemIdentifier, KMDocumentFormToolbarItemIdentifier, KMDocumentEditToolbarItemIdentifier,
  41. KMDocumentDigitalSignToolbarItemIdentifier,KMDocumentSignToolbarItemIdentifier,
  42. KMDocumentFillSginToolbarItemIdentifier, KMDocumentToolToolbarItemIdentifier, KMDocumentPrintToolbarItemIdentifier,
  43. KMDocumentShareToolbarItemIdentifier, KMDocumentSearchToolbarItemIdentifier, KMRightControlToolbarItemIdentifier,
  44. KMDocumentPreviousBackToolbarItemIdentifier, KMDocumentFirstLastToolbarItemIdentifier,
  45. // KMDocumentPageIndicatorToolbarItemIdentifier,
  46. KMDocumentPresentationToolbarItemIdentifier, KMDocumentPageInputToolbarItemIdentifier]
  47. /// annotation
  48. //
  49. let KMToolbarMoveToolModeItemIdentifier = "KMToolbarPreviousItemIdentifier"
  50. let KMToolbarMagnifyToolModeItemIdentifier = "KMToolbarMagnifyToolModeItemIdentifier"
  51. let KMToolbarSelectToolModeItemIdentifier = "KMToolbarSelectToolModeItemIdentifier"
  52. let KMToolbarZoomToSelectionItemIdentifier = "KMToolbarZoomToSelectionItemIdentifier"
  53. let KMToolbarHighlightAnnotationItemIdentifier = "KMToolbarHighlightAnnotationItemIdentifier"
  54. let KMToolbarUnderlineAnnotationItemIdentifier = "KMToolbarUnderlineAnnotationItemIdentifier"
  55. let KMToolbarStrikeOutAnnotationItemIdentifier = "KMToolbarStrikeOutAnnotationItemIdentifier"
  56. let KMToolbarSquigglyAnnotationItemIdentifier = "KMToolbarSquigglyAnnotationItemIdentifier"
  57. let KMToolbarInkAnnotationItemIdentifier = "KMToolbarInkAnnotationItemIdentifier"
  58. let KMToolbarEraserAnnotationItemIdentifier = "KMToolbarEraserAnnotationItemIdentifier"
  59. let KMToolbarFreeTextAnnotationItemIdentifier = "KMToolbarFreeTextAnnotationItemIdentifier"
  60. let KMToolbarAnchoredAnnotationItemIdentifier = "KMToolbarAnchoredAnnotationItemIdentifier"
  61. let KMToolbarSquareAnnotationItemIdentifier = "KMToolbarSquareAnnotationItemIdentifier"
  62. let KMToolbarCircleAnnotationItemIdentifier = "KMToolbarCircleAnnotationItemIdentifier"
  63. let KMToolbarLineAnnotationItemIdentifier = "KMToolbarLineAnnotationItemIdentifier"
  64. let KMToolbarArrowAnnotationItemIdentifier = "KMToolbarArrowAnnotationItemIdentifier"
  65. let KMToolbarLinkAnnotationItemIdentifier = "KMToolbarLinkAnnotationItemIdentifier"
  66. let KMToolbarSignSignatureAnnotationItemIdentifier = "KMToolbarSignatureAnnotationItemIdentifier"
  67. let KMAnnotationStampToolbarItemIdentifier = "KMToolbarStampAnnotationItemIdentifier"
  68. let KMAnnotationImageToolbarItemIdentifier = "KMToolbarImageAnnotationItemIdentifier"
  69. let KMAnnotationTableToolbarItemIdentifier = "KMToolbarTableAnnotationItemIdentifier"
  70. let KMToolbarShowToolbarItemIdentifier = "KMToolbarShowToolbarItemIdentifier"
  71. let KMToolbarAnnotationSettingItemIdentifier = "KMToolbarAnnotationSettingItemIdentifier"
  72. let annotationToolIdentifiers = [KMToolbarMoveToolModeItemIdentifier, KMToolbarMagnifyToolModeItemIdentifier, KMToolbarSelectToolModeItemIdentifier,
  73. KMToolbarZoomToSelectionItemIdentifier, KMToolbarHighlightAnnotationItemIdentifier, KMToolbarUnderlineAnnotationItemIdentifier,
  74. KMToolbarStrikeOutAnnotationItemIdentifier, KMToolbarSquigglyAnnotationItemIdentifier, KMToolbarInkAnnotationItemIdentifier, KMToolbarEraserAnnotationItemIdentifier,
  75. KMToolbarFreeTextAnnotationItemIdentifier,
  76. KMToolbarAnchoredAnnotationItemIdentifier, KMToolbarSquareAnnotationItemIdentifier, KMToolbarCircleAnnotationItemIdentifier,
  77. KMToolbarLineAnnotationItemIdentifier, KMToolbarArrowAnnotationItemIdentifier, KMToolbarLinkAnnotationItemIdentifier,
  78. KMToolbarSignSignatureAnnotationItemIdentifier, KMAnnotationStampToolbarItemIdentifier, KMAnnotationImageToolbarItemIdentifier, KMAnnotationTableToolbarItemIdentifier, KMToolbarAnnotationSettingItemIdentifier, KMToolbarShowToolbarItemIdentifier]
  79. // PageEdit
  80. let KMToolbarPageEditPageRangeItemIdentifier = "KMToolbarPageEditPageRangeItemIdentifier"
  81. let KMToolbarPageEditRotateItemIdentifier = "KMToolbarPageEditRotateItemIdentifier"
  82. let KMToolbarPageEditLeftRotateItemIdentifier = "KMToolbarPageEditLeftRotateItemIdentifier"
  83. let KMToolbarPageEditRightRotateItemIdentifier = "KMToolbarPageEditRightRotateItemIdentifier"
  84. let KMToolbarPageEditInsetItemIdentifier = "KMToolbarPageEditInsertItemIdentifier"
  85. let KMToolbarPageEditExtractItemIdentifier = "KMToolbarPageEditExtractItemIdentifier"
  86. let KMToolbarPageEditReplaceItemIdentifier = "KMToolbarPageEditReplaceItemIdentifier"
  87. let KMToolbarPageEditSplitItemIdentifier = "KMToolbarPageEditSplitItemIdentifier"
  88. let KMToolbarPageEditReverseItemIdentifier = "KMToolbarPageEditReverseItemIdentifier"
  89. let KMToolbarPageEditCopyItemIdentifier = "KMToolbarPageEditCopyItemIdentifier"
  90. let KMToolbarPageEditPasteItemIdentifier = "KMToolbarPageEditPasteItemIdentifier"
  91. let KMToolbarPageEditDeleteItemIdentifier = "KMToolbarPageEditDeleteItemIdentifier"
  92. let pageEditToolIdentifiers = [KMToolbarPageEditPageRangeItemIdentifier, KMToolbarPageEditRotateItemIdentifier,
  93. KMToolbarPageEditLeftRotateItemIdentifier,KMToolbarPageEditRightRotateItemIdentifier,
  94. KMToolbarPageEditInsetItemIdentifier, KMToolbarPageEditExtractItemIdentifier,
  95. KMToolbarPageEditReplaceItemIdentifier, KMToolbarPageEditSplitItemIdentifier,
  96. KMToolbarPageEditReverseItemIdentifier, KMToolbarPageEditCopyItemIdentifier,
  97. KMToolbarPageEditPasteItemIdentifier, KMToolbarPageEditDeleteItemIdentifier]
  98. // conversion
  99. let KMToolbarConversionCreatePDFItemIdentifier = "KMToolbarImageToPDFItemIdentifier"
  100. let KMToolbarConversionWordItemIdentifier = "KMToolbarPDFToWordItemIdentifier"
  101. let KMToolbarConversionExcelItemIdentifier = "KMToolbarPDFToExcelItemIdentifier"
  102. let KMToolbarConversionPPTItemIdentifier = "KMToolbarPDFToPPTItemIdentifier"
  103. let KMToolbarConversionRTFItemIdentifier = "KMToolbarPDFToRTFItemIdentifier"
  104. let KMToolbarConversionCSVItemIdentifier = "KMToolbarPDFToCSVItemIdentifier"
  105. let KMToolbarConversionHTMLItemIdentifier = "KMToolbarPDFToHtmlItemIdentifier"
  106. let KMToolbarConversionTextItemIdentifier = "KMToolbarPDFToTextItemIdentifier"
  107. let KMToolbarConversionImageItemIdentifier = "KMToolbarPDFToImageItemIdentifier"
  108. let KMToolbarConversionImageToPDFItemIdentifier = "KMToolbarImageToPDFNewItemIdentifier"
  109. let KMToolbarConversionOtherItemIdentifier = "KMToolbarPDFToOtherItemIdentifier"
  110. let KMToolbarConversionOCRIdentifier = "KMToolbarConversionOCRIdentifier"
  111. let KMToolbarConversionExportImageItemIdentifier = "KMToolbarExtractPDFImageItemIdentifier"
  112. let conversionToolIdentifiers = [KMToolbarConversionCreatePDFItemIdentifier,
  113. KMToolbarConversionWordItemIdentifier, KMToolbarConversionExcelItemIdentifier,
  114. KMToolbarConversionPPTItemIdentifier, KMToolbarConversionRTFItemIdentifier,
  115. KMToolbarConversionCSVItemIdentifier, KMToolbarConversionHTMLItemIdentifier,
  116. KMToolbarConversionTextItemIdentifier, KMToolbarConversionImageItemIdentifier, KMToolbarConversionImageToPDFItemIdentifier, KMToolbarConversionOtherItemIdentifier,
  117. KMToolbarConversionOCRIdentifier, KMToolbarConversionExportImageItemIdentifier]
  118. // EditPDF
  119. let KMToolbarAddTextEditPDFItemIdentifier = "KMToolbarAddTextEditPDFItemIdentifier"
  120. let KMToolbarAddImageEditPDFItemIdentifier = "KMToolbarAddImageEditPDFItemIdentifier"
  121. let editPDFItemIdentifiers = [KMToolbarAddTextEditPDFItemIdentifier, KMToolbarAddImageEditPDFItemIdentifier]
  122. let KMToolbarDividerItemIdentifier = "KMToolbarDividerItemIdentifier"
  123. /// Tool
  124. let KMToolbarToolCropItemIdentifier = "KMToolbarToolCropItemIdentifier"
  125. let KMToolbarToolBatesItemIdentifier = "KMToolbarBatesItemIdentifier"
  126. let KMToolbarToolHeaderFooterItemIdentifier = "KMToolbarHeaderFooterItemIdentifier"
  127. let KMToolbarToolBackgroundItemIdentifier = "KMToolbarBackgroundItemIdentifier"
  128. let KMToolbarToolWatermarkItemIdentifier = "KMToolbarWatermarkItemIdentifier"
  129. let KMToolbarToolRedactItemIdentifier = "KMToolbarToolRedactItemIdentifier"
  130. let KMToolbarToolCompressItemIdentifier = "KMToolbarCompressionItemIdentifier"
  131. let KMToolbarToolSecureItemIdentifier = "KMToolbarSecurityItemIdentifier"
  132. let KMToolbarToolMergeItemIdentifier = "KMToolbarMergeItemIdentifier"
  133. let KMToolbarComparisonItemIdentifier = "KMToolbarComparisonItemIdentifier"
  134. let KMToolbarMeasureItemIdentifier = "KMToolbarMeasureItemIdentifier"
  135. let KMToolbarAIItemIdentifier = "KMToolbarAIItemIdentifier"
  136. let toolToolIdentifiers = [KMToolbarToolCropItemIdentifier, KMToolbarToolBatesItemIdentifier,
  137. KMToolbarToolHeaderFooterItemIdentifier, KMToolbarToolBackgroundItemIdentifier,
  138. KMToolbarToolWatermarkItemIdentifier, KMToolbarToolRedactItemIdentifier,
  139. KMToolbarToolCompressItemIdentifier, KMToolbarToolSecureItemIdentifier,
  140. KMToolbarToolMergeItemIdentifier,KMToolbarComparisonItemIdentifier,
  141. KMToolbarMeasureItemIdentifier]
  142. /// Form
  143. let KMToolbarToolTextFieldItemIdentifier = "KMToolbarFormTextFieldItemIdentifier"
  144. let KMToolbarToolCheckBoxItemIdentifier = "KMToolbarFormCheckBoxItemIdentifier"
  145. let KMToolbarToolRadioButtonItemIdentifier = "KMToolbarFormRadioButtonItemIdentifier"
  146. let KMToolbarToolListBoxItemIdentifier = "KMToolbarToolListBoxItemIdentifier"
  147. let KMToolbarToolPullDownmenuItemIdentifier = "KMToolbarFormComboBoxItemIdentifier"
  148. let KMToolbarToolButtonIdentifier = "KMToolbarFormActionButtonItemIdentifier"
  149. let KMToolbarToolSignBoxIdentifier = "KMToolbarFormSignatureButtonItemIdentifier"
  150. let KMToolbarToolFormAlignIdentifier = "KMToolbarFormAlignmentIdentifier"
  151. let KMToolbarToolFormMoreIdentifier = "KMToolbarToolFormMoreIdentifier"
  152. let formToolIdentifiers = [KMToolbarToolTextFieldItemIdentifier, KMToolbarToolCheckBoxItemIdentifier,
  153. KMToolbarToolRadioButtonItemIdentifier, KMToolbarToolListBoxItemIdentifier,
  154. KMToolbarToolPullDownmenuItemIdentifier, KMToolbarToolButtonIdentifier,
  155. KMToolbarToolSignBoxIdentifier, KMToolbarToolFormAlignIdentifier,
  156. KMToolbarToolFormMoreIdentifier]
  157. /// FillSign
  158. let KMToolbarToolHookItemIdentifier = "KMToolbarToolHookItemIdentifier"
  159. let KMToolbarToolForkItemIdentifier = "KMToolbarToolForkItemIdentifier"
  160. let KMToolbarToolLineItemIdentifier = "KMToolbarToolLineItemIdentifier"
  161. let KMToolbarToolDotItemIdentifier = "KMToolbarToolDotItemIdentifier"
  162. let KMToolbarToolRectangleIdentifier = "KMToolbarToolRectangleIdentifier"
  163. let KMToolbarToolTextIdentifier = "KMToolbarToolTextIdentifier"
  164. let KMToolbarToolDateIdentifier = "KMToolbarToolDateIdentifier"
  165. let KMToolbarToolProfileIdentifier = "KMToolbarToolProfileIdentifier"
  166. let KMToolbarFillSignSignatureIdentifier = "KMToolbarFillSignSignatureIdentifier"
  167. let fillSignToolIdentifiers = [KMToolbarToolHookItemIdentifier, KMToolbarToolForkItemIdentifier,
  168. KMToolbarToolLineItemIdentifier, KMToolbarToolDotItemIdentifier,
  169. KMToolbarToolRectangleIdentifier, KMToolbarToolTextIdentifier,
  170. KMToolbarToolDateIdentifier, KMToolbarToolProfileIdentifier,
  171. KMToolbarFillSignSignatureIdentifier]
  172. //Scan OCR
  173. let KMToolbarToolOCRTextIdentifier = "KMToolbarToolOCRTextIdentifier"
  174. let KMToolbarToolEnhancedScanIdentifier = "KMToolbarToolEnhancedScanIdentifier"
  175. let KMToolbarViewSettingIdentifier = "KMToolbarSplitScreenModeItemIdentifier"
  176. let KMToolbarCropIdentifier = "KMToolbarCropItemIdentifier"
  177. let KMToolbarSnapshotIdentifier = "KMToolbarTakeSnapshotItemIdentifier"
  178. let KMToolbarTTSIdentifier = "KMToolbarTTSViewItemIdentifier"
  179. let KMViewDisplayIdentifiers = [KMToolbarViewSettingIdentifier, KMToolbarCropIdentifier, KMToolbarSnapshotIdentifier, KMToolbarTTSIdentifier]
  180. let KMSignDigitalSignToolbarItemIdentifier = "KMSignDigitalSignToolbarItemIdentifier"
  181. let KMSignIdentifiers = [KMToolbarToolSignBoxIdentifier, KMSignDigitalSignToolbarItemIdentifier]
  182. let KMNewToolbarSpaceItemIdentifier = "KMNewToolbarSpaceItemIdentifier"
  183. //let KMToolbarDividerItemIdentifier = "KMToolbarDividerItemIdentifier"
  184. // 固定宽度
  185. let KMToolbarFixedSpaceItemIdentifier = "fixedSpaceItemIdentifier"
  186. // 可变宽度
  187. let KMToolbarFlexibleSpaceItemIdentifier = "flexibleSpaceItemIdentifier"
  188. let KMToolBarToolPDFShapeStyle = "KMToolBarToolPDFShapeStyle"
  189. public func parentIdentifier(_ identifier: String) -> String {
  190. if (isMainToolItem(identifier)) {
  191. return ""
  192. }
  193. if (editPDFItemIdentifiers.contains(identifier)) {
  194. return KMDocumentEditToolbarItemIdentifier
  195. }
  196. if (annotationToolIdentifiers.contains(identifier)) {
  197. return KMDocumentAnnotationToolbarItemIdentifier
  198. }
  199. if (pageEditToolIdentifiers.contains(identifier)) {
  200. return KMDocumentPageToolbarItemIdentifier
  201. }
  202. if (conversionToolIdentifiers.contains(identifier)) {
  203. return KMDocumentConversonToolbarItemIdentifier
  204. }
  205. if (toolToolIdentifiers.contains(identifier)) {
  206. return KMDocumentToolToolbarItemIdentifier
  207. }
  208. if (formToolIdentifiers.contains(identifier)) {
  209. return KMDocumentFormToolbarItemIdentifier
  210. }
  211. if (fillSignToolIdentifiers.contains(identifier)) {
  212. return KMDocumentFillSginToolbarItemIdentifier
  213. }
  214. if KMViewDisplayIdentifiers.contains(identifier) {
  215. return KMDocumentViewDisplayToolbarItemIdentifier
  216. }
  217. return ""
  218. }
  219. public func isMainToolItem(_ identifier: String) -> Bool {
  220. if (mainToolIdentifiers.contains(identifier)) {
  221. return true
  222. }
  223. return false
  224. }