Browse Source

Merge branch 'develop' of git.kdan.cc:Mac_PDF/PDF_Office into develop

tangchao 1 year ago
parent
commit
9aaa63cba3

+ 0 - 4
PDF Office/PDF Master/Class/PDFWindowController/Side/LeftSide/Thumbnail/KMThumbnailViewController.swift

@@ -53,10 +53,6 @@ class KMThumbnailViewController: NSViewController {
         self.thumbnailView.reloadData()
     }
     
-    override func centerSelectionInVisibleArea(_ sender: Any?) {
-        super.centerSelectionInVisibleArea(sender)
-    }
-    
     override func viewDidLoad() {
         super.viewDidLoad()
         self.view.wantsLayer = true

+ 29 - 25
PDF Office/PDF Master/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -523,7 +523,11 @@ extension KMMainViewController {
             if (point == nil) {
                 point = NSZeroPoint
             }
-            let pagePoint = self.listView.convert(point!, to: self.listView.currentPage())
+            
+            let currentPoint: NSPoint = self.listView.convert(point!, from: self.listView.superview)
+            let currentPage = self.listView.page(for: currentPoint, nearest: true)
+            let pagePoint = self.listView.convert(currentPoint, to: currentPage)
+            
             var annotation: CPDFAnnotation?
             
             if self.isReadMode {
@@ -535,39 +539,39 @@ extension KMMainViewController {
                     self.listView.annotationType = CAnnotationType.ink
                 case 1:
 //                    self.listView.annotationType = CAnnotationType.freeText
-                    let defaultSize = self.listView.defaultSize(with: .freeText, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .freeText, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .freeText, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .freeText, selection: nil, page: currentPage, bounds: bounds)
                     if ((annotation) != nil) {
                         self.listView.updateActiveAnnotations([annotation!])
                         self.listView.edit(annotation)
                     }
                 case 2:
 //                    self.listView.annotationType = CAnnotationType.anchored
-                    let defaultSize = self.listView.defaultSize(with: .anchored, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .anchored, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .anchored, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .anchored, selection: nil, page: currentPage, bounds: bounds)
                     self.listView.edit(annotation)
                 case 3:
 //                    self.listView.annotationType = CAnnotationType.square
-                    let defaultSize = self.listView.defaultSize(with: .square, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .square, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .square, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .square, selection: nil, page: currentPage, bounds: bounds)
                 case 4:
 //                    self.listView.annotationType = CAnnotationType.circle
-                    let defaultSize = self.listView.defaultSize(with: .circle, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .circle, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .circle, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .circle, selection: nil, page: currentPage, bounds: bounds)
                 case 5:
 //                    self.listView.annotationType = CAnnotationType.arrow
-                    let defaultSize = self.listView.defaultSize(with: .arrow, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .arrow, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .arrow, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .arrow, selection: nil, page: currentPage, bounds: bounds)
                 case 6:
 //                    self.listView.annotationType = CAnnotationType.line
-                    let defaultSize = self.listView.defaultSize(with: .line, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .line, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .line, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .line, selection: nil, page: currentPage, bounds: bounds)
                 case 7:
                     self.listView.annotationType = CAnnotationType.link
                     self.openRightPane()
@@ -595,9 +599,9 @@ extension KMMainViewController {
                     self.listView.annotationType = CAnnotationType.ink
                 case 1:
 //                    self.listView.annotationType = CAnnotationType.freeText
-                    let defaultSize = self.listView.defaultSize(with: .freeText, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .freeText, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .freeText, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .freeText, selection: nil, page: currentPage, bounds: bounds)
 //                    self.view.window?.makeFirstResponder()
                     if ((annotation) != nil) {
                         self.listView.updateActiveAnnotations([annotation!])
@@ -605,30 +609,30 @@ extension KMMainViewController {
                     }
                 case 2:
 //                    self.listView.annotationType = CAnnotationType.anchored
-                    let defaultSize = self.listView.defaultSize(with: .anchored, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .anchored, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .anchored, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .anchored, selection: nil, page: currentPage, bounds: bounds)
                     self.listView.edit(annotation)
                 case 3:
 //                    self.listView.annotationType = CAnnotationType.square
-                    let defaultSize = self.listView.defaultSize(with: .square, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .square, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .square, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .square, selection: nil, page: currentPage, bounds: bounds)
                 case 4:
 //                    self.listView.annotationType = CAnnotationType.circle
-                    let defaultSize = self.listView.defaultSize(with: .circle, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .circle, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .circle, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .circle, selection: nil, page: currentPage, bounds: bounds)
                 case 5:
 //                    self.listView.annotationType = CAnnotationType.arrow
-                    let defaultSize = self.listView.defaultSize(with: .arrow, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .arrow, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .arrow, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .arrow, selection: nil, page: currentPage, bounds: bounds)
                 case 6:
 //                    self.listView.annotationType = CAnnotationType.line
-                    let defaultSize = self.listView.defaultSize(with: .line, in: self.listView.currentPage())
+                    let defaultSize = self.listView.defaultSize(with: .line, in: currentPage)
                     let bounds = CPDFListViewRectFromCenterAndSize(CPDFListViewIntegralPoint(pagePoint), defaultSize)
-                    annotation = self.listView.addAnnotation(with: .line, selection: nil, page: self.listView.currentPage(), bounds: bounds)
+                    annotation = self.listView.addAnnotation(with: .line, selection: nil, page: currentPage, bounds: bounds)
                 case 7:
                     self.listView.annotationType = CAnnotationType.link
                     self.openRightPane()