KMNPopAnnotationWindowController.swift 53 KB

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