Forráskód Böngészése

【2025】【PDFView】注释旋转支持Undo/Redo

zenghong 2 hónapja
szülő
commit
4efcb45359

+ 10 - 0
PDF Office/PDF Master/KMClass/KMPDFViewController/KMMainViewController.swift

@@ -3521,6 +3521,16 @@ extension KMMainViewController: KMPDFToolbarControllerDelegate {
 
 //MARK: - KMRightSideControllerDelegate右边属性栏代理
 extension KMMainViewController: KMRightSideControllerDelegate {
+    func kmRightSideControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) {
+        CPDFStampAnnotation.rotateLeft(annotations, withPDFView: pdfView)
+        (undoManager?.prepare(withInvocationTarget: self) as AnyObject).kmRightSideControllerRotateRight(annotations, withPDFView: pdfView)
+    }
+    
+    func kmRightSideControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) {
+        CPDFStampAnnotation.rotateRight(annotations, withPDFView: pdfView)
+        (undoManager?.prepare(withInvocationTarget: self) as AnyObject).kmRightSideControllerRotateLeft(annotations, withPDFView: pdfView)
+    }
+    
     func kmRightSideControllerDidContendVCUpdated(_ controller: KMRightSideController) {
         //MARK: -Crop
         if (controller.contentViewController is KMCropPropertyController) {

+ 16 - 1
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/KMRightSideController.swift

@@ -15,6 +15,9 @@ import KMComponentLibrary
     //OCR
     @objc func kmRightSideControllerOCRShowTypeChange(_ controller: KMRightSideController, _ type: KMOCRShowType)
     @objc func kmRightSideControllerOCRDoneAction(_ controller: KMRightSideController, _ model: KMOCRModel)
+    
+    @objc func kmRightSideControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?)
+    @objc func kmRightSideControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?)
 }
 
 class KMRightSideController: NSViewController {
@@ -460,7 +463,7 @@ class KMRightSideController: NSViewController {
                         stamp_Controller = KMStampController.init()
                     }
                     stamp_Controller?.pdfView = self.pdfView
-                    
+                    stamp_Controller?.delegate = self
                     contentViewController = stamp_Controller
                 }
             } else if subToolMode == .Stamp {
@@ -749,3 +752,15 @@ extension KMRightSideController: KMStampListControllerDelegate {
         reloadTopRightButtonInfo()
     }
 }
+
+extension KMRightSideController: KMStampControllerDelegate {
+    func kmStampControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) {
+        delegate?.kmRightSideControllerRotateLeft(annotations, withPDFView: pdfView)
+    }
+
+    func kmStampControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) {
+        delegate?.kmRightSideControllerRotateRight(annotations, withPDFView: pdfView)
+    }
+}
+
+

+ 10 - 6
PDF Office/PDF Master/KMClass/KMPDFViewController/RightSideController/Views/StampList/KMStampController.swift

@@ -8,6 +8,13 @@
 import Cocoa
 import KMComponentLibrary
 
+@objc protocol KMStampControllerDelegate: AnyObject {
+        
+    //注释旋转
+    @objc func kmStampControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?)
+    @objc func kmStampControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?)
+}
+
 class KMStampController: NSViewController {
     
     @IBOutlet var rotateBGView: NSView!
@@ -18,6 +25,7 @@ class KMStampController: NSViewController {
     private var annotations: [CPDFStampAnnotation] = []
     var pdfView: CPDFListView?
     
+    weak open var delegate: KMStampControllerDelegate?
     
     //MARK: - func
     override func viewDidAppear() {
@@ -69,14 +77,10 @@ class KMStampController: NSViewController {
     //MARK: - Action
     @objc func buttonClicked(_ button: ComponentButton) {
         if button == rotateLeftButton {
-            CPDFStampAnnotation.rotateLeft(annotations, withPDFView: pdfView)
+            delegate?.kmStampControllerRotateLeft(annotations, withPDFView: pdfView)
         } else if button == rotateRightButton {
-            CPDFStampAnnotation.rotateRight(annotations, withPDFView: pdfView)
+            delegate?.kmStampControllerRotateRight(annotations, withPDFView: pdfView)
         }
         
     }
-    
-    
-    
-    
 }