瀏覽代碼

【2025】【PDFView】注释旋转新接口串接

zenghong 2 月之前
父節點
當前提交
15e07eb7b9

+ 2 - 20
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFStampAnnotation+PDFListView.swift

@@ -30,16 +30,7 @@ extension CPDFStampAnnotation {
         for annotation in annotations {
             var rotation = annotation.annotationRotation
             rotation += 90
-            annotation.annotationRotation = rotation
-            
-            var rect = annotation.bounds
-            let width = rect.size.width
-            let height = rect.size.height
-            rect.origin.x = rect.origin.x + (width - height)/2.0
-            rect.origin.y = rect.origin.y - (width - height)/2.0
-            rect.size.width = height
-            rect.size.height = width
-            annotation.bounds = rect
+            annotation.updateRotation(rotation)
             
         }
         pdfView.setNeedsDisplayMultiAnnotations(annotations)
@@ -54,16 +45,7 @@ extension CPDFStampAnnotation {
             var rotation = annotation.annotationRotation
             rotation -= 90
             
-            annotation.annotationRotation = rotation
-            
-            var rect = annotation.bounds
-            let width = rect.size.width
-            let height = rect.size.height
-            rect.origin.x = rect.origin.x + (width - height)/2.0
-            rect.origin.y = rect.origin.y - (width - height)/2.0
-            rect.size.width = height
-            rect.size.height = width
-            annotation.bounds = rect
+            annotation.updateRotation(rotation)
             
         }
         pdfView.setNeedsDisplayMultiAnnotations(annotations)

+ 81 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFListViewExtension/CPDFListView+Event.m

@@ -3878,6 +3878,78 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
         if (self.pdfListViewDelegate && [self.pdfListViewDelegate respondsToSelector:@selector(PDFListViewAnnotationMeasureInfoChange:withAnnotation:)]) {
             [self.pdfListViewDelegate PDFListViewAnnotationMeasureInfoChange:self withAnnotation:(CPDFPolygonAnnotation *)activeAnnotation];
         }
+    } else if ([activeAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
+        CPDFStampAnnotation *stampAnnotation = (CPDFStampAnnotation *)activeAnnotation;
+        CPDFStampDraggedType draggedIndex = -1;
+        if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 2;
+        } else if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 4;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 6;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 0;
+        } else if (resizeHandle & CMinXEdgeMask) {
+            draggedIndex = 7;
+        } else if (resizeHandle & CMaxXEdgeMask) {
+            draggedIndex = 3;
+        } else if (resizeHandle & CMinYEdgeMask) {
+            draggedIndex = 1;
+        } else if (resizeHandle & CMaxYEdgeMask) {
+            draggedIndex = 5;
+        }
+        if (draggedIndex == -1) {
+            return;
+        }
+        [stampAnnotation dragStampAnnotationWithCurrentPagePoint:currentPagePoint draggedIndex:draggedIndex];
+    } else if ([activeAnnotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
+        CPDFSignatureAnnotation *signatureAnnotation = (CPDFSignatureAnnotation *)activeAnnotation;
+        CPDFSignatureDraggedType draggedIndex = -1;
+        if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 2;
+        } else if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 4;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 6;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 0;
+        } else if (resizeHandle & CMinXEdgeMask) {
+            draggedIndex = 7;
+        } else if (resizeHandle & CMaxXEdgeMask) {
+            draggedIndex = 3;
+        } else if (resizeHandle & CMinYEdgeMask) {
+            draggedIndex = 1;
+        } else if (resizeHandle & CMaxYEdgeMask) {
+            draggedIndex = 5;
+        }
+        if (draggedIndex == -1) {
+            return;
+        }
+        [signatureAnnotation dragSignatureAnnotationWithCurrentPagePoint:currentPagePoint draggedIndex:draggedIndex];
+    } else if ([activeAnnotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
+        CPDFSignatureWidgetAnnotation *signatureWidgetAnnotation = (CPDFSignatureWidgetAnnotation *)activeAnnotation;
+        CPDFSignatureWidgetDraggedType draggedIndex = -1;
+        if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 2;
+        } else if ((resizeHandle & CMaxXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 4;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMaxYEdgeMask)) {
+            draggedIndex = 6;
+        } else if ((resizeHandle & CMinXEdgeMask) && (resizeHandle & CMinYEdgeMask)) {
+            draggedIndex = 0;
+        } else if (resizeHandle & CMinXEdgeMask) {
+            draggedIndex = 7;
+        } else if (resizeHandle & CMaxXEdgeMask) {
+            draggedIndex = 3;
+        } else if (resizeHandle & CMinYEdgeMask) {
+            draggedIndex = 1;
+        } else if (resizeHandle & CMaxYEdgeMask) {
+            draggedIndex = 5;
+        }
+        if (draggedIndex == -1) {
+            return;
+        }
+        [signatureWidgetAnnotation dragSignatureWidgetAnnotationWithCurrentPagePoint:currentPagePoint draggedIndex:draggedIndex];
     } else {
         [activeAnnotation setBounds:NSIntegralRect(newBounds)];
     }
@@ -4773,6 +4845,15 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                     [polygonAnnotation setMeasureInfo:me];
                 }
             }
+        } else if ([activeAnnotation isKindOfClass:[CPDFStampAnnotation class]]) {
+            CPDFStampAnnotation *stampAnnotation = (CPDFStampAnnotation *)activeAnnotation;
+            [stampAnnotation moveStampAnnotationWithActivePage:stampAnnotation.page offset:offset];
+        } else if ([activeAnnotation isKindOfClass:[CPDFSignatureAnnotation class]]) {
+            CPDFSignatureAnnotation *signatureAnnotation = (CPDFSignatureAnnotation *)activeAnnotation;
+            [signatureAnnotation moveSignatureAnnotationWithActivePage:signatureAnnotation.page offset:offset];
+        } else if ([activeAnnotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
+            CPDFSignatureWidgetAnnotation *signatureWidgetAnnotation = (CPDFSignatureWidgetAnnotation *)activeAnnotation;
+            [signatureWidgetAnnotation moveSignatureWidgetAnnotationWithActivePage:signatureWidgetAnnotation.page offset:offset];
         } else {
             [activeAnnotation setBounds:newBounds];
         }