PublicKey.swift 17 KB

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