KMNPopAnnotationWindowController.swift 53 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120
  1. //
  2. // KMNPopAnnotationWindowController.swift
  3. // PDF Reader Pro
  4. //
  5. // Created by 丁林圭 on 2024/12/2.
  6. //
  7. import Cocoa
  8. import KMComponentLibrary
  9. let popOffSet:CGFloat = 8.0
  10. typealias PaneCallback = (_ isOpenPane: Bool) -> ()
  11. typealias UpdatePDFViewCallback = () -> ()
  12. class KMNPopOperationWindow: NSWindow {
  13. override var canBecomeKey: Bool {
  14. return true
  15. }
  16. override var canBecomeMain: Bool {
  17. return true
  18. }
  19. }
  20. class KMNPopAnnotationWindowController: KMNBaseWindowController {
  21. public var popType:ListViewPopType = .popTypeNone {
  22. didSet {
  23. rightOffsetConstraint.constant = 49.0
  24. operationHeightConstraint.constant = 32.0
  25. paneBox.isHidden = false
  26. switch popType {
  27. case .generaAnnotation :
  28. generaPopView.layoutSubtreeIfNeeded()
  29. operationWidthConstraint.constant = generaPopView.bounds.width
  30. self.window?.display() //需刷新约束才会有值,不然会变化
  31. operationBox.contentView = generaPopView
  32. congfigGeneraPopUI()
  33. break
  34. case .freeTextAnnotation:
  35. fontPopView.layoutSubtreeIfNeeded()
  36. operationWidthConstraint.constant = fontPopView.bounds.width
  37. self.window?.display() //需刷新约束才会有值,不然会变化
  38. operationBox.contentView = fontPopView
  39. break
  40. case .shapeAnnotation:
  41. var isContainSelfDot = false
  42. for i in 0..<annotationPopMode.annotations.count {
  43. if let selfAn = annotationPopMode.annotations[i] as? CSelfSignAnnotation {
  44. if selfAn.annotationType == .signDot {
  45. isContainSelfDot = true
  46. break
  47. }
  48. }
  49. }
  50. var width = 272.0
  51. if isContainSelfDot == true {
  52. shapeRightConstraint.constant = 0
  53. widthZoomOutButton.isHidden = true
  54. widthZoomInButton.isHidden = true
  55. width = 200.0
  56. } else {
  57. shapeRightConstraint.constant = 72
  58. widthZoomOutButton.isHidden = false
  59. widthZoomInButton.isHidden = false
  60. }
  61. shapeView.layoutSubtreeIfNeeded()
  62. // operationWidthConstraint.constant = shapeView.bounds.width //刷新后未更新最后的宽度,暂时写死宽度
  63. operationWidthConstraint.constant = width
  64. self.window?.display() //需刷新约束才会有值,不然会变化
  65. operationBox.contentView = shapeView
  66. congfigShapePopUI()
  67. break
  68. case .linkAnnotation:
  69. if let newLinkAnnotation = annotationPopMode.annotation as? CPDFLinkAnnotation {
  70. linkAnnotation = newLinkAnnotation
  71. }
  72. break
  73. case .formAnnotation:
  74. formRightConstraint.constant = 0
  75. gropNameInput.isHidden = true
  76. formView.layoutSubtreeIfNeeded()
  77. operationWidthConstraint.constant = formView.bounds.width
  78. self.window?.display() //需刷新约束才会有值,不然会变化
  79. operationBox.contentView = formView
  80. break
  81. case .formRadioAnnotation:
  82. formRightConstraint.constant = 110
  83. gropNameInput.isHidden = false
  84. formView.layoutSubtreeIfNeeded()
  85. operationWidthConstraint.constant = formView.bounds.width
  86. self.window?.display() //需刷新约束才会有值,不然会变化
  87. operationBox.contentView = formView
  88. break
  89. case .multpleAnnotation:
  90. alightView.layoutSubtreeIfNeeded()
  91. operationWidthConstraint.constant = alightView.bounds.width
  92. self.window?.display() //需刷新约束才会有值,不然会变化
  93. operationBox.contentView = alightView
  94. break
  95. case .popTypeNone:
  96. break
  97. }
  98. }
  99. }
  100. public var isOpenPane = false {
  101. didSet {
  102. if isOpenPane == true {
  103. paneSelectorItem.properties.state = .pressed
  104. } else {
  105. paneSelectorItem.properties.state = .normal
  106. }
  107. paneSelectorItem.reloadData()
  108. }
  109. }
  110. public var annotationPopMode:KMNAnnotationPopMode = KMNAnnotationPopMode(pdfAnnotations: []) {
  111. didSet {
  112. let annotationPopType = annotationPopMode.popType
  113. popType = annotationPopType
  114. if annotationPopType == .generaAnnotation {
  115. let newColor = annotationPopMode.annotationColor()
  116. annotationColor = newColor
  117. } else if(annotationPopType == .shapeAnnotation) {
  118. let newColor = annotationPopMode.annotationColor()
  119. annotationColor = newColor
  120. } else if(annotationPopType == .freeTextAnnotation) {
  121. let newColor = annotationPopMode.annotationFontColor()
  122. fontColor = newColor
  123. let alignment = annotationPopMode.annotationAlignment()
  124. fontAlight = alignment
  125. let font = annotationPopMode.annotationFontName()
  126. compdfFont = font
  127. } else if annotationPopType == .linkAnnotation {
  128. if annotationPopMode.annotation != nil {
  129. linkAnnotation = annotationPopMode.annotation as! CPDFLinkAnnotation
  130. }
  131. } else if annotationPopType == .formAnnotation {
  132. fildNameString = annotationPopMode.annotationFieldName() ?? ""
  133. } else if annotationPopType == .formRadioAnnotation {
  134. fildNameString = annotationPopMode.annotationFieldName() ?? ""
  135. gropNameString = annotationPopMode.annotationGropName() ?? ""
  136. }
  137. }
  138. }
  139. private var annotationColor:NSColor?{
  140. didSet {
  141. if popType == .generaAnnotation {
  142. generaColorGroup.currentColor = annotationColor
  143. generaColorGroup.refreshUI()
  144. } else if popType == .shapeAnnotation {
  145. shapeColorGroup.currentColor = annotationColor
  146. shapeColorGroup.refreshUI()
  147. }
  148. }
  149. }
  150. private var fontColor:NSColor?{
  151. didSet {
  152. fontColorItem.properties?.color = fontColor
  153. fontColorItem.reloadData()
  154. }
  155. }
  156. private var linkAnnotation:CPDFLinkAnnotation = CPDFLinkAnnotation(){
  157. didSet {
  158. if let destination = linkAnnotation.destination() {
  159. linkType = .page
  160. } else if let annotationURL = linkAnnotation.url(){
  161. var urlString = annotationURL.fileURL.absoluteString
  162. if annotationURL.hasPrefix("mailto:") {
  163. linkType = .email
  164. } else {
  165. linkType = .url
  166. }
  167. } else {
  168. linkType = .linkSetting
  169. }
  170. }
  171. }
  172. private var fildNameString:String = ""{
  173. didSet {
  174. fildNameInput.properties.text = fildNameString
  175. fildNameInput.reloadData()
  176. }
  177. }
  178. private var gropNameString:String = ""{
  179. didSet {
  180. gropNameInput.properties.text = gropNameString
  181. gropNameInput.reloadData()
  182. }
  183. }
  184. private var compdfFont:CPDFFont?{
  185. didSet {
  186. if(compdfFont != nil) {
  187. let styleName = compdfFont!.styleName
  188. if(styleName?.isEmpty == true) {
  189. fontNameSelect.properties.text = compdfFont!.familyName
  190. } else {
  191. fontNameSelect.properties.text = compdfFont!.familyName + "-" + (compdfFont!.styleName ?? "")
  192. }
  193. } else {
  194. fontNameSelect.properties.text = "-"
  195. }
  196. fontNameSelect.reloadData()
  197. }
  198. }
  199. private var fontAlight:NSTextAlignment = .left {
  200. didSet {
  201. if fontAlight == .center {
  202. fontAlightButton.properties.icon = NSImage(named: "KMNImageNameListViewPopAlightCenter")
  203. } else if fontAlight == .right {
  204. fontAlightButton.properties.icon = NSImage(named: "KMNImageNameListViewPopAlightRight")
  205. } else {
  206. fontAlightButton.properties.icon = NSImage(named: "KMNImageNameListViewPopAlightLeft")
  207. }
  208. fontAlightButton.reloadData()
  209. }
  210. }
  211. private var objectAlignType:ObjectAlignType = .alightLeft {
  212. didSet {
  213. let activeAnnotations = annotationPopMode.annotations
  214. switch objectAlignType {
  215. case .alightLeft :
  216. listView?.change(activeAnnotations, alignmentType: .left)
  217. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightLeft")
  218. break
  219. case .alightRight:
  220. listView?.change(activeAnnotations, alignmentType: .right)
  221. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightRight")
  222. break
  223. case .alightTop:
  224. listView?.change(activeAnnotations, alignmentType: .top)
  225. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightTop")
  226. break
  227. case .alightVer:
  228. listView?.change(activeAnnotations, alignmentType: .vertical)
  229. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightVer")
  230. break
  231. case .alightHor:
  232. listView?.change(activeAnnotations, alignmentType: .horizontally)
  233. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightHor")
  234. break
  235. case .alightBottom:
  236. listView?.change(activeAnnotations, alignmentType: .bottom)
  237. alightButton.properties.icon = NSImage(named: "KMNImageNameObjectPopAlightBottom")
  238. break
  239. case .averageVer:
  240. listView?.change(activeAnnotations, alignmentType: .disVertical)
  241. alightButton.properties.icon = NSImage(named: "KMNImageNameObjecAlignAverageVer")
  242. break
  243. case .averageHor:
  244. listView?.change(activeAnnotations, alignmentType: .disHorizontally)
  245. alightButton.properties.icon = NSImage(named: "KMNImageNameObjecAlignAverageHor")
  246. break
  247. }
  248. alightButton.reloadData()
  249. }
  250. }
  251. var paneCallback: PaneCallback?
  252. var updatePDFViewCallback: UpdatePDFViewCallback?
  253. static let shared: KMNPopAnnotationWindowController = {
  254. let windowC = KMNPopAnnotationWindowController(windowNibName: "KMNPopAnnotationWindowController")
  255. return windowC
  256. }()
  257. var linkType:linkDetailType = .linkSetting {
  258. didSet {
  259. if linkType == .linkSetting {
  260. linkView.layoutSubtreeIfNeeded()
  261. rightOffsetConstraint.constant = 45.0
  262. operationHeightConstraint.constant = 32.0
  263. operationWidthConstraint.constant = linkView.bounds.width
  264. self.window?.display() //需刷新约束才会有值,不然会变化
  265. operationBox.contentView = linkView
  266. paneBox.isHidden = false
  267. } else if linkType == .page {
  268. linkPageDetailView.layoutSubtreeIfNeeded()
  269. rightOffsetConstraint.constant = 8
  270. operationWidthConstraint.constant = linkPageDetailView.bounds.width
  271. operationHeightConstraint.constant = 224
  272. self.window?.display() //需刷新约束才会有值,不然会变化
  273. operationBox.contentView = linkPageDetailView
  274. paneBox.isHidden = true
  275. if let destination = linkAnnotation.destination() {
  276. reloadPageUrlData()
  277. refreshPageThum()
  278. } else {
  279. paginationView.properties.currentIndex = Int(((listView?.currentPageIndex ?? 0) + 1))
  280. paginationView.reloadData()
  281. refreshPageThum()
  282. }
  283. } else if linkType == .url {
  284. linkUrlDetailView.layoutSubtreeIfNeeded()
  285. rightOffsetConstraint.constant = 8
  286. operationWidthConstraint.constant = linkUrlDetailView.bounds.width
  287. operationHeightConstraint.constant = linkUrlDetailView.bounds.height
  288. self.window?.display() //需刷新约束才会有值,不然会变化
  289. operationBox.contentView = linkUrlDetailView
  290. paneBox.isHidden = true
  291. urlInput.properties.placeholder = KMNCompanyWebsite
  292. if let annotationURL = linkAnnotation.url(){
  293. if annotationURL.hasPrefix("mailto:") {
  294. urlInput.properties.text = ""
  295. } else {
  296. urlInput.properties.text = annotationURL
  297. }
  298. } else {
  299. urlInput.properties.text = ""
  300. }
  301. urlInput.properties.state = .pressed
  302. urlInput.beginEditing()
  303. urlInput.reloadData()
  304. } else if linkType == .email {
  305. linkUrlDetailView.layoutSubtreeIfNeeded()
  306. rightOffsetConstraint.constant = 8
  307. operationWidthConstraint.constant = linkUrlDetailView.bounds.width
  308. operationHeightConstraint.constant = linkUrlDetailView.bounds.height
  309. self.window?.display() //需刷新约束才会有值,不然会变化
  310. operationBox.contentView = linkUrlDetailView
  311. paneBox.isHidden = true
  312. urlInput.properties.placeholder = KMNCompanyEamil
  313. if let annotationURL = linkAnnotation.url(){
  314. if annotationURL.hasPrefix("mailto:") {
  315. if let range = annotationURL.range(of: "mailto:") {
  316. let trimmedString = String(annotationURL[range.upperBound...])
  317. urlInput.properties.text = trimmedString
  318. }
  319. } else {
  320. urlInput.properties.text = ""
  321. }
  322. } else {
  323. urlInput.properties.text = ""
  324. }
  325. urlInput.properties.state = .pressed
  326. urlInput.beginEditing()
  327. urlInput.reloadData()
  328. }
  329. updateFrame(listView: listView ?? CPDFListView())
  330. }
  331. }
  332. @IBOutlet weak var contentBox: NSBox!
  333. @IBOutlet weak var operationBox: NSBox!
  334. @IBOutlet weak var paneBox: NSBox!
  335. @IBOutlet weak var lineBox: NSBox!
  336. @IBOutlet var paneSelectorItem: ComponentCSelector!
  337. @IBOutlet weak var operationWidthConstraint: NSLayoutConstraint!
  338. @IBOutlet weak var rightOffsetConstraint: NSLayoutConstraint!
  339. @IBOutlet weak var operationHeightConstraint: NSLayoutConstraint!
  340. @IBOutlet var generaPopView: NSView!
  341. @IBOutlet var generaColorGroup: ComponentCColorGroup!
  342. @IBOutlet var fontPopView: NSView!
  343. @IBOutlet var fontColorItem: ComponentCColorItem!
  344. @IBOutlet var fontNameSelect: ComponentSelect!
  345. @IBOutlet var fontSizeZoomOutButton: ComponentButton!
  346. @IBOutlet var fontSizeZoomInButton: ComponentButton!
  347. @IBOutlet var fontAlightButton: ComponentButton!
  348. @IBOutlet var shapeView: NSView!
  349. @IBOutlet var shapeColorGroup: ComponentCColorGroup!
  350. @IBOutlet var widthZoomOutButton: ComponentButton!
  351. @IBOutlet var widthZoomInButton: ComponentButton!
  352. @IBOutlet weak var shapeRightConstraint: NSLayoutConstraint!
  353. @IBOutlet var linkView: NSView!
  354. @IBOutlet var pageLinkButton: ComponentButton!
  355. @IBOutlet var urlLinkButton: ComponentButton!
  356. @IBOutlet var emailLinkButton: ComponentButton!
  357. @IBOutlet weak var pageLinkWidthConstraint: NSLayoutConstraint!
  358. @IBOutlet weak var urlLinkWidthConstraint: NSLayoutConstraint!
  359. @IBOutlet weak var emailLinkWidthConstraint: NSLayoutConstraint!
  360. @IBOutlet var formView: NSView!
  361. @IBOutlet var fildNameInput: ComponentInput!
  362. @IBOutlet var gropNameInput: ComponentInput!
  363. @IBOutlet var formRightConstraint: NSLayoutConstraint!
  364. @IBOutlet var alightView: NSView!
  365. @IBOutlet var alightButton: ComponentButton!
  366. @IBOutlet var linkPageDetailView: NSView!
  367. @IBOutlet var backPageLinkButton: ComponentButton!
  368. @IBOutlet var paginationView: ComponentPagination!
  369. @IBOutlet var paginationDesBox: NSBox!
  370. @IBOutlet var pageThumImageView: NSImageView!
  371. @IBOutlet var goPageLinkButton: ComponentButton!
  372. @IBOutlet weak var backPageWidthConstraint: NSLayoutConstraint!
  373. @IBOutlet var linkUrlDetailView: NSView!
  374. @IBOutlet var backUrlLinkButton: ComponentButton!
  375. @IBOutlet var goUrlLinkButton: ComponentButton!
  376. @IBOutlet var urlInput: ComponentInput!
  377. @IBOutlet weak var backUrlWidthConstraint: NSLayoutConstraint!
  378. private var fontPopover:NSPopover?
  379. private var ObjectPopover:NSPopover?
  380. weak var listView:CPDFListView? {
  381. didSet {
  382. paginationView.properties.totalCount = Int(listView?.document.pageCount ?? 1)
  383. paginationView.reloadData()
  384. }
  385. }
  386. override func windowDidLoad() {
  387. super.windowDidLoad()
  388. }
  389. override func initContentView() {
  390. super.initContentView()
  391. configFormPopUI()
  392. congfigFontPopUI()
  393. congfigGeneraPopUI()
  394. congfigShapePopUI()
  395. paneSelectorItem.properties = ComponentCSelectorProperty(iconImage:NSImage(named: "KMNImageNameListViewPopPane"))
  396. paneSelectorItem.setTarget(self, action: #selector(paneButtonClicked(_ :)))
  397. fontSizeZoomOutButton.properties = ComponentButtonProperty(type: .text_gray,
  398. size: .s,
  399. state: .normal,
  400. onlyIcon: true,
  401. icon:NSImage(named: "KMNImageNameListViewPopFontSizeZoomOut"),
  402. keepPressState: false)
  403. fontSizeZoomOutButton.setTarget(self, action: #selector(fontSizeZoomOutButtonClicked(_ :)))
  404. fontSizeZoomInButton.properties = ComponentButtonProperty(type: .text_gray,
  405. size: .s,
  406. state: .normal,
  407. onlyIcon: true,
  408. icon:NSImage(named: "KMNImageNameListViewPopFontSizeZoomIn"),
  409. keepPressState: false)
  410. fontSizeZoomInButton.setTarget(self, action: #selector(fontSizeZoomInButtonClicked(_ :)))
  411. fontAlightButton.properties = ComponentButtonProperty(type: .text_gray,
  412. size: .s,
  413. state: .normal,
  414. onlyIcon: true,
  415. icon:NSImage(named: "KMNImageNameListViewPopAlightLeft"))
  416. fontAlightButton.setTarget(self, action: #selector(fontAlightButtonClicked(_ :)))
  417. widthZoomOutButton.properties = ComponentButtonProperty(type: .text_gray,
  418. size: .s,
  419. state: .normal,
  420. onlyIcon: true,
  421. icon:NSImage(named: "KMNImageNameListViewPopWidthZoomOut"),
  422. keepPressState: false)
  423. widthZoomOutButton.setTarget(self, action: #selector(widthZoomOutButtonClicked(_ :)))
  424. widthZoomInButton.properties = ComponentButtonProperty(type: .text_gray,
  425. size: .s,
  426. state: .normal,
  427. onlyIcon: true,
  428. icon:NSImage(named: "KMNImageNameListViewPopWidthZoomIn"),
  429. keepPressState: false)
  430. widthZoomInButton.setTarget(self, action: #selector(widthZoomInButtonClicked(_ :)))
  431. pageLinkButton.setTarget(self, action: #selector(pageLinkButtonClicked(_ :)))
  432. urlLinkButton.setTarget(self, action: #selector(urlLinkButtonClicked(_ :)))
  433. emailLinkButton.setTarget(self, action: #selector(emailLinkButtonClicked(_ :)))
  434. alightButton.properties = ComponentButtonProperty(type: .text_gray,
  435. size: .s,
  436. state: .normal,
  437. onlyIcon: true,
  438. icon:NSImage(named: "KMNImageNameObjectPopAlightLeft"))
  439. alightButton.setTarget(self, action: #selector(alightButtonClicked(_ :)))
  440. goUrlLinkButton.properties = ComponentButtonProperty(type: .text_gray,
  441. size: .s,
  442. state: .normal,
  443. onlyIcon: true,
  444. icon:NSImage(named: "KMNImageNamePopLinkGO"),keepPressState: false)
  445. goUrlLinkButton.setTarget(self, action: #selector(linkGoButtonClicked(_ :)))
  446. goPageLinkButton.properties = ComponentButtonProperty(type: .text_gray,
  447. size: .s,
  448. state: .normal,
  449. onlyIcon: true,
  450. icon:NSImage(named: "KMNImageNamePopLinkGO"),keepPressState: false)
  451. goPageLinkButton.setTarget(self, action: #selector(linkGoButtonClicked(_ :)))
  452. paginationView.properties = ComponentPaginationProperty(doubleArrow_show: false, currentIndex: 0, totalCount: 1)
  453. paginationView.delegate = self
  454. let inputFiedProperty: ComponentInputProperty = ComponentInputProperty(size: .s,
  455. state:.pressed ,
  456. isError: false,
  457. showPrefix: false,
  458. showSuffix: false,
  459. showClear: false,
  460. isDisabled: false,
  461. placeholder: KMNCompanyWebsite,
  462. text: "")
  463. urlInput.properties = inputFiedProperty
  464. urlInput.delegate = self
  465. }
  466. override func updateUIThemeColor() {
  467. super.updateUIThemeColor()
  468. lineBox.fillColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider")
  469. contentBox.fillColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/popup")
  470. contentBox.borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/3-default")
  471. paginationDesBox.fillColor = ComponentLibrary.shared.getComponentColorFromKey("colorFill/4")
  472. paginationDesBox.borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/4")
  473. pageThumImageView.wantsLayer = true
  474. paginationDesBox.layer?.borderColor = ComponentLibrary.shared.getComponentColorFromKey("colorBorder/divider").cgColor
  475. }
  476. override func updateUILanguage() {
  477. super.updateUILanguage()
  478. pageLinkButton.properties = ComponentButtonProperty(type: .text_gray,
  479. size: .s,
  480. state: .normal,
  481. onlyIcon: false,
  482. showLeftIcon:true,
  483. buttonText:KMLocalizedString("Page"),
  484. icon:NSImage(named: "KMNImageNameListViewLinkPage"),keepPressState: false)
  485. urlLinkButton.properties = ComponentButtonProperty(type: .text_gray,
  486. size: .s,
  487. state: .normal,
  488. onlyIcon: false,
  489. showLeftIcon:true,
  490. buttonText:KMLocalizedString("Web"),
  491. icon:NSImage(named: "KMNImageNameListViewLinkUrl"),keepPressState: false)
  492. emailLinkButton.properties = ComponentButtonProperty(type: .text_gray,
  493. size: .s,
  494. state: .normal,
  495. onlyIcon: false,
  496. showLeftIcon:true,
  497. buttonText:KMLocalizedString("Email"),
  498. icon:NSImage(named: "KMNImageNameListViewLinkEmail"),keepPressState: false)
  499. pageLinkWidthConstraint.constant = pageLinkButton.properties.propertyInfo.viewWidth
  500. urlLinkWidthConstraint.constant = urlLinkButton.properties.propertyInfo.viewWidth
  501. emailLinkWidthConstraint.constant = emailLinkButton.properties.propertyInfo.viewWidth
  502. backUrlLinkButton.properties = ComponentButtonProperty(type: .text_primary,
  503. size: .s,
  504. state: .normal,
  505. onlyIcon: false,
  506. showLeftIcon: true,
  507. buttonText: KMLocalizedString("Back"),
  508. icon:NSImage(named: "KMNImageNamePopLinkBack"),keepPressState: false)
  509. backUrlLinkButton.setTarget(self, action: #selector(linkBackButtonClicked(_ :)))
  510. backUrlWidthConstraint.constant = backUrlLinkButton.properties.propertyInfo.viewWidth
  511. backUrlLinkButton.reloadData()
  512. backPageLinkButton.properties = ComponentButtonProperty(type: .text_primary,
  513. size: .s,
  514. onlyIcon: false,
  515. showLeftIcon:true,
  516. buttonText: KMLocalizedString("Back"),
  517. icon:NSImage(named: "KMNImageNamePopLinkBack"),keepPressState: false)
  518. backPageLinkButton.setTarget(self, action: #selector(linkBackButtonClicked(_ :)))
  519. backPageWidthConstraint.constant = backPageLinkButton.properties.propertyInfo.viewWidth
  520. }
  521. //MARK: - Public
  522. public func updateFrame(listView:CPDFListView) {
  523. let activeAnnotations = annotationPopMode.annotations
  524. let page = activeAnnotations.first?.page
  525. let windowFram = listView.window?.frame ?? CGRectZero
  526. if(page != nil) {
  527. let pageRect = listView.selectionMultipleBounds(with: activeAnnotations)
  528. let positioningRect = listView.convert(pageRect, from: page!)
  529. if (CGRectIntersectsRect(positioningRect, listView.frame)) {
  530. let view: NSView? = nil
  531. let position = listView.convert(positioningRect, to: view)
  532. var positionNew = position.origin
  533. positionNew.x += windowFram.origin.x + position.width/2
  534. positionNew.y += windowFram.origin.y + position.height
  535. var positionRect = self.window?.frame ?? CGRectZero
  536. positionRect.origin.x = positionNew.x - positionRect.width/2
  537. positionRect.origin.y = positionNew.y + popOffSet
  538. var listViewWindRect = listView.convert(listView.frame, to: view)
  539. listViewWindRect.origin.x += windowFram.origin.x
  540. listViewWindRect.origin.y += windowFram.origin.y
  541. if CGRectGetMaxY(positionRect) > CGRectGetMaxY(listViewWindRect) {
  542. positionRect.origin.y = positionNew.y - popOffSet - position.height - positionRect.size.height
  543. }
  544. if CGRectGetMinX(positionRect) < CGRectGetMinX(listViewWindRect) {
  545. positionRect.origin.x = CGRectGetMinX(listViewWindRect)
  546. }
  547. if CGRectGetMaxX(positionRect) > CGRectGetMaxX(listViewWindRect) {
  548. positionRect.origin.x = CGRectGetMaxX(listViewWindRect) - positionRect.width
  549. }
  550. self.window?.setFrame(positionRect, display: true)
  551. updateUILanguage()
  552. } else {
  553. }
  554. }
  555. }
  556. public func closeWindow(listView:CPDFListView?) {
  557. if self.window?.isVisible == true {
  558. listView?.window?.removeChildWindow(self.window ?? NSWindow())
  559. self.window?.close()
  560. }
  561. if ObjectPopover?.isShown == true {
  562. ObjectPopover?.close()
  563. }
  564. if fontPopover?.isShown == true {
  565. fontPopover?.close()
  566. }
  567. }
  568. //MARK: - private
  569. private func congfigGeneraPopUI() {
  570. var colors = KMAnnotationPropertiesColorManager.manager.markHighlightColors
  571. if(annotationPopMode.annotation is CPDFMarkupAnnotation) {
  572. let markupAnnotation:CPDFMarkupAnnotation = annotationPopMode.annotation as! CPDFMarkupAnnotation
  573. if markupAnnotation.markupType() == .highlight {
  574. colors = KMAnnotationPropertiesColorManager.manager.markHighlightColors
  575. } else {
  576. colors = KMAnnotationPropertiesColorManager.manager.markOtherColors
  577. }
  578. } else if (annotationPopMode.annotation is CPDFInkAnnotation) {
  579. colors = KMAnnotationPropertiesColorManager.manager.inkColors
  580. } else if (annotationPopMode.annotation is CPDFTextAnnotation) {
  581. colors = KMAnnotationPropertiesColorManager.manager.noteColors
  582. }
  583. let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[0])
  584. let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[1])
  585. let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[2])
  586. let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[3])
  587. let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: colors[4])
  588. generaColorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
  589. generaColorGroup.delegate = self
  590. }
  591. private func congfigFontPopUI() {
  592. fontNameSelect.properties = ComponentSelectProperties(size: .s,
  593. state: .normal,
  594. isDisabled: false,
  595. isError: false,
  596. leftIcon: false,
  597. placeholder: nil,
  598. errorText: nil,
  599. creatable: false,
  600. text: NSLocalizedString("", comment: ""))
  601. fontNameSelect.delegate = self
  602. var menuItemArr: [ComponentMenuitemProperty] = []
  603. for familyName in CPDFFont.familyNames {
  604. let fontNames = CPDFFont.fontNames(forFamilyName: familyName)
  605. let itemProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
  606. itemSelected: false,
  607. isDisabled: false,
  608. keyEquivalent: nil,
  609. text: familyName,identifier: "1")
  610. var subMenuItemArr: [ComponentMenuitemProperty] = []
  611. for fontName in fontNames {
  612. let subItemProperty: ComponentMenuitemProperty = ComponentMenuitemProperty(multipleSelect: false,
  613. itemSelected: false,
  614. isDisabled: false,
  615. keyEquivalent: nil,
  616. text: fontName,identifier: "2")
  617. subMenuItemArr.append(subItemProperty)
  618. }
  619. itemProperty.subPropertys = subMenuItemArr
  620. menuItemArr.append(itemProperty)
  621. }
  622. fontNameSelect.updateMenuItemsArr(menuItemArr)
  623. fontColorItem.properties = ComponentCColorProperty(colorType: .color,
  624. state: .normal,
  625. isCustom: true,
  626. color: NSColor.red)
  627. fontColorItem.delegate = self
  628. fontColorItem.reloadData()
  629. }
  630. private func congfigShapePopUI() {
  631. var colors = KMAnnotationPropertiesColorManager.manager.inkColors
  632. let annotation = annotationPopMode.annotation ?? CPDFAnnotation()
  633. if annotation.isKind(of: CPDFInkAnnotation.self) {
  634. colors = KMAnnotationPropertiesColorManager.manager.inkColors
  635. } else if annotation.isKind(of: CPDFCircleAnnotation.self) ||
  636. annotation.isKind(of: CPDFSquareAnnotation.self) {
  637. colors = KMAnnotationPropertiesColorManager.manager.inkColors
  638. } else if annotation.isKind(of: CPDFLineAnnotation.self) {
  639. if let lineAnnotation:CPDFLineAnnotation = annotation as? CPDFLineAnnotation {
  640. if lineAnnotation.isMeasure {
  641. colors = KMAnnotationPropertiesColorManager.manager.measure_Border_Colors
  642. } else {
  643. if lineAnnotation.endLineStyle == .none && lineAnnotation.startPoint == .none {
  644. colors = KMAnnotationPropertiesColorManager.manager.lineColors
  645. } else {
  646. colors = KMAnnotationPropertiesColorManager.manager.arrowColors
  647. }
  648. }
  649. }
  650. } else if (annotation.isKind(of: CPDFPolygonAnnotation.self) ||
  651. annotation.isKind(of: CPDFPolylineAnnotation.self)) {
  652. colors = KMAnnotationPropertiesColorManager.manager.measure_Border_Colors
  653. } else if annotation.isKind(of: CPDFTextAnnotation.self) {
  654. colors = KMAnnotationPropertiesColorManager.manager.noteColors
  655. } else if annotation.isKind(of: CSelfSignAnnotation.self) {
  656. colors = KMAnnotationPropertiesColorManager.manager.fill_tickColors
  657. }
  658. let colorAProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[0])
  659. let colorBProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[1])
  660. let colorCProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[2])
  661. let colorDProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: false, color: colors[3])
  662. let colorEProperty = ComponentCColorProperty(colorType: .color, state: .normal, isCustom: true, color: colors[4])
  663. shapeColorGroup.setUpWithColorPropertys([colorAProperty, colorBProperty, colorCProperty, colorDProperty], customItemProperty: colorEProperty)
  664. shapeColorGroup.delegate = self
  665. }
  666. private func configFormPopUI() {
  667. let inputFiedProperty: ComponentInputProperty = ComponentInputProperty(size: .s,
  668. state:.pressed ,
  669. isError: false,
  670. showPrefix: false,
  671. showSuffix: false,
  672. showClear: false,
  673. isDisabled: false,
  674. placeholder: "File Name",
  675. text: "")
  676. fildNameInput.properties = inputFiedProperty
  677. fildNameInput.delegate = self
  678. let inputGropProperty: ComponentInputProperty = ComponentInputProperty(size: .s,
  679. state:.pressed ,
  680. isError: false,
  681. showPrefix: false,
  682. showSuffix: false,
  683. showClear: false,
  684. isDisabled: false,
  685. placeholder: "Grop Name",
  686. text: "")
  687. gropNameInput.properties = inputGropProperty
  688. gropNameInput.delegate = self
  689. }
  690. private func reloadPageUrlData() {
  691. if let destination = linkAnnotation.destination() {
  692. if let page = destination.page() {
  693. paginationView.properties.currentIndex = Int(page.pageIndex() + 1)
  694. paginationView.reloadData()
  695. return
  696. }
  697. }
  698. paginationView.properties.currentIndex = Int(((listView?.currentPageIndex ?? 0) + 1))
  699. paginationView.reloadData()
  700. }
  701. private func refreshPageThum() {
  702. guard let pdfView = listView else {
  703. return
  704. }
  705. let thumbnail = KMNThumbnail.init(document: pdfView.document, currentPageIndex:Int(paginationView.properties.currentIndex - 1))
  706. thumbnail.generateThumImage {[weak self] image in
  707. self?.pageThumImageView.image = image
  708. }
  709. }
  710. //MARK: - Action
  711. @objc func paneButtonClicked(_ sender: NSView) {
  712. isOpenPane = !isOpenPane
  713. paneCallback?(isOpenPane)
  714. }
  715. @objc func fontSizeZoomOutButtonClicked(_ sender: NSView) {
  716. if let freeText = annotationPopMode.annotation as? CPDFFreeTextAnnotation {
  717. if listView?.isEdit(withCurrentFreeText: freeText) == true {
  718. listView?.commitEditAnnotationFreeText(freeText)
  719. }
  720. if annotationPopMode.zoomOutFontSize() {
  721. updatePDFViewCallback?()
  722. }
  723. }
  724. }
  725. @objc func fontSizeZoomInButtonClicked(_ sender: NSView) {
  726. if let freeText = annotationPopMode.annotation as? CPDFFreeTextAnnotation {
  727. if listView?.isEdit(withCurrentFreeText: freeText) == true {
  728. listView?.commitEditAnnotationFreeText(freeText)
  729. }
  730. if annotationPopMode.zoomInFontSize() {
  731. updatePDFViewCallback?()
  732. }
  733. }
  734. }
  735. @objc func fontAlightButtonClicked(_ sender: NSView) {
  736. if fontPopover?.isShown == true {
  737. fontPopover?.close()
  738. } else {
  739. let vc = KMNPopDetailsViewController(nibName: "KMNPopDetailsViewController", bundle: nil)
  740. let createFilePopover: NSPopover = NSPopover.init()
  741. createFilePopover.contentViewController = vc
  742. createFilePopover.delegate = self
  743. createFilePopover.animates = true
  744. createFilePopover.behavior = .semitransient
  745. createFilePopover.setValue(true, forKey: "shouldHideAnchor")
  746. createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 20, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
  747. vc.detailPopType = .freeTextAlight
  748. vc.fontChangeAlighCallback = { [weak self] alight in
  749. if let freeText = self?.annotationPopMode.annotation as? CPDFFreeTextAnnotation {
  750. if self?.listView?.isEdit(withCurrentFreeText: freeText) == true {
  751. self?.listView?.commitEditAnnotationFreeText(freeText)
  752. }
  753. }
  754. self?.annotationPopMode.setAnnotationAlignment(annotationAlignment: alight)
  755. self?.updatePDFViewCallback?()
  756. self?.fontAlight = alight
  757. }
  758. fontPopover = createFilePopover
  759. vc.fontAlight = fontAlight
  760. }
  761. }
  762. @objc func widthZoomOutButtonClicked(_ sender: NSView) {
  763. if annotationPopMode.zoomOutShapeWidth() {
  764. updatePDFViewCallback?()
  765. }
  766. }
  767. @objc func widthZoomInButtonClicked(_ sender: NSView) {
  768. if annotationPopMode.zoomInShapeWidth() {
  769. updatePDFViewCallback?()
  770. }
  771. }
  772. @objc func pageLinkButtonClicked(_ sender: NSView) {
  773. linkType = .page
  774. }
  775. @objc func urlLinkButtonClicked(_ sender: NSView) {
  776. linkType = .url
  777. }
  778. @objc func emailLinkButtonClicked(_ sender: NSView) {
  779. linkType = .email
  780. }
  781. @objc func alightButtonClicked(_ sender: NSView) {
  782. if ObjectPopover?.isShown == true {
  783. ObjectPopover?.close()
  784. } else {
  785. let vc = KMNPopDetailsViewController(nibName: "KMNPopDetailsViewController", bundle: nil)
  786. let createFilePopover: NSPopover = NSPopover.init()
  787. createFilePopover.contentViewController = vc
  788. createFilePopover.delegate = self
  789. createFilePopover.animates = true
  790. createFilePopover.behavior = .semitransient
  791. createFilePopover.setValue(true, forKey: "shouldHideAnchor")
  792. createFilePopover.show(relativeTo: CGRect(x: sender.bounds.origin.x, y: 20, width: sender.bounds.size.width, height: sender.bounds.size.height), of: sender, preferredEdge: .maxY)
  793. if (annotationPopMode.annotations.count == 2) {
  794. vc.detailPopType = .freeTextDoubleAlight
  795. } else if (annotationPopMode.annotations.count > 2) {
  796. vc.detailPopType = .freeTextMultpleAlight
  797. }
  798. vc.objectChangeAlighCallback = { [weak self] alight in
  799. self?.objectAlignType = alight
  800. self?.updatePDFViewCallback?()
  801. }
  802. ObjectPopover = createFilePopover
  803. vc.objectAlignType = objectAlignType
  804. }
  805. }
  806. @objc func linkGoButtonClicked(_ sender: NSView) {
  807. if linkType == .url {
  808. guard let webString = linkAnnotation.url() else { return }
  809. if let data = URL(string: webString) {
  810. NSWorkspace.shared.open(data)
  811. }
  812. } else if linkType == .email {
  813. guard let emailString = linkAnnotation.url() else {
  814. let alert = NSAlert()
  815. alert.alertStyle = .critical
  816. alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
  817. alert.runModal()
  818. return
  819. }
  820. if KMNTools.isValidateEmail(emailString) {
  821. let alert = NSAlert()
  822. alert.alertStyle = .critical
  823. alert.messageText = NSLocalizedString("Invalid Email. Please try again.", comment: "")
  824. alert.runModal()
  825. } else {
  826. NSWorkspace.shared.open(URL(string: emailString)!)
  827. }
  828. } else if linkType == .page {
  829. if let destination = linkAnnotation.destination() {
  830. listView?.go(to: destination)
  831. closeWindow(listView: listView)
  832. }
  833. }
  834. }
  835. @objc func linkBackButtonClicked(_ sender: NSView) {
  836. linkType = .linkSetting
  837. }
  838. @objc func fontColorChange(_ sender: Any) {
  839. if let color = (sender as? NSColorPanel)?.color {
  840. if let freeText = annotationPopMode.annotation as? CPDFFreeTextAnnotation {
  841. if listView?.isEdit(withCurrentFreeText: freeText) == true {
  842. listView?.commitEditAnnotationFreeText(freeText)
  843. }
  844. }
  845. annotationPopMode.setAnnotationFontColor(annotationFontColor: color)
  846. fontColor = color
  847. updatePDFViewCallback?()
  848. }
  849. }
  850. }
  851. //MARK: - ComponentCColorDelegate
  852. extension KMNPopAnnotationWindowController: ComponentCColorDelegate {
  853. func componentCColorDidChooseColor(_ view: NSView, _ color: NSColor?) {
  854. if(view == generaColorGroup) {
  855. self.annotationPopMode.setAnnotationColor(annotationColor: color)
  856. updatePDFViewCallback?()
  857. } else if (view == shapeColorGroup) {
  858. self.annotationPopMode.setAnnotationColor(annotationColor: color)
  859. updatePDFViewCallback?()
  860. } else if (view == fontColorItem) {
  861. fontColorItem.properties?.state = .normal
  862. fontColorItem.reloadData()
  863. let colorPanel = NSColorPanel.shared
  864. colorPanel.setTarget(self)
  865. colorPanel.showsAlpha = false
  866. colorPanel.setAction(#selector(self.fontColorChange(_:)))
  867. colorPanel.orderFront(nil)
  868. }
  869. }
  870. }
  871. //MARK: - ComponentInputDelegate
  872. extension KMNPopAnnotationWindowController: ComponentInputDelegate {
  873. func componentInputDidChanged(inputView: ComponentInput) {
  874. if (inputView == fildNameInput) {
  875. for i in 0 ..< annotationPopMode.annotations.count {
  876. let annotation = annotationPopMode.annotations[i]
  877. if let widgt = annotation as? CPDFWidgetAnnotation {
  878. widgt.setFieldName(inputView.properties.text)
  879. }
  880. }
  881. updatePDFViewCallback?()
  882. } else if (inputView == gropNameInput) {
  883. for i in 0 ..< annotationPopMode.annotations.count {
  884. let annotation = annotationPopMode.annotations[i]
  885. if let button = annotation as? CPDFButtonWidgetAnnotation {
  886. button.setButtonWidgetStateString(inputView.properties.text)
  887. }
  888. }
  889. updatePDFViewCallback?()
  890. } else if (inputView == urlInput) {
  891. if linkType == .email {
  892. let emailString = urlInput.properties.text
  893. if KMNTools.isValidateEmail(emailString) {
  894. linkAnnotation.setDestination(nil)
  895. let linkUrlPath = KMNTools.judgeEmailURL(emailString)
  896. linkAnnotation.setURL(linkUrlPath)
  897. updatePDFViewCallback?()
  898. }
  899. } else if linkType == .url {
  900. let webString = urlInput.properties.text
  901. linkAnnotation.setDestination(nil)
  902. let linkUrlPath = KMNTools.judgeWebURL(webString)
  903. linkAnnotation.setURL(linkUrlPath)
  904. updatePDFViewCallback?()
  905. }
  906. }
  907. }
  908. func componentInputDidEndEditing(inputView: ComponentInput) {
  909. if (inputView == fildNameInput) {
  910. } else if (inputView == gropNameInput) {
  911. } else if (inputView == urlInput) {
  912. }
  913. }
  914. }
  915. //MARK: - ComponentSelectDelegate
  916. extension KMNPopAnnotationWindowController: ComponentSelectDelegate {
  917. func componentSelectDidSelect(view: ComponentSelect?, menuItemProperty: ComponentMenuitemProperty?) {
  918. if(view == fontNameSelect) {
  919. if menuItemProperty?.identifier == "1" {
  920. let familyName = fontNameSelect.properties.text ?? "Helvetica"
  921. let styles = CPDFFont.fontNames(forFamilyName: familyName)
  922. compdfFont = CPDFFont(familyName: familyName, fontStyle: styles.first ?? "")
  923. annotationPopMode.setAnnotationFont(font: compdfFont ?? CPDFFont.init(familyName: "Helvetica", fontStyle: ""))
  924. updatePDFViewCallback?()
  925. } else if menuItemProperty?.identifier == "2"{ //字体样式
  926. compdfFont = CPDFFont(familyName: compdfFont?.familyName ?? "Helvetica", fontStyle: menuItemProperty?.text ?? "")
  927. annotationPopMode.setAnnotationFont(font: compdfFont ?? CPDFFont.init(familyName: "Helvetica", fontStyle: ""))
  928. updatePDFViewCallback?()
  929. }
  930. }
  931. }
  932. }
  933. //MARK: - ComponentSelectDelegate
  934. extension KMNPopAnnotationWindowController: NSPopoverDelegate {
  935. func popoverWillClose(_ notification: Notification) {
  936. if fontPopover == (notification.object as? NSPopover) {
  937. if(fontAlightButton.properties.state == .pressed) {
  938. fontAlightButton.properties.state = .normal
  939. fontAlightButton.reloadData()
  940. }
  941. } else if ObjectPopover == (notification.object as? NSPopover) {
  942. if(alightButton.properties.state == .pressed) {
  943. alightButton.properties.state = .normal
  944. alightButton.reloadData()
  945. }
  946. }
  947. }
  948. }
  949. //MARK: - ComponentPaginationDelegate
  950. extension KMNPopAnnotationWindowController: ComponentPaginationDelegate {
  951. public func componentPaginationDidValueChanged(pagination: ComponentPagination) {
  952. let pageIndex = pagination.properties.currentIndex
  953. if let page = listView?.document.page(at: UInt(pageIndex)) {
  954. linkAnnotation.setURL(nil)
  955. let destination = CPDFDestination(document: listView?.document ?? CPDFDocument(), pageIndex: Int(paginationView.properties.currentIndex - 1))
  956. linkAnnotation.setDestination(destination)
  957. refreshPageThum()
  958. reloadPageUrlData()
  959. updatePDFViewCallback?()
  960. }
  961. }
  962. }