Quellcode durchsuchen

【PDFListView】线段注释多选时位置偏差问题

dinglingui vor 1 Jahr
Ursprung
Commit
073112665a

+ 2 - 2
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFLineAnnotation+PDFListView.m

@@ -48,7 +48,7 @@
             point = [self endPoint];
             CPDFListViewDrawResizeHandle(context, point, delta, YES);
         } else {
-            NSRect rect = [self borderRecctForView:pdfView];
+            NSRect rect = [self bounds];
             CGFloat lineWidth = [pdfView unitWidthOnPage:[self page]];
             CGContextSaveGState(context);
             CGColorRef color = [CPDFListViewConfig defaultManager].annotationBorderColor.CGColor;
@@ -57,7 +57,7 @@
             if(isHover) {
                 CGFloat length[] = {5,5};
                 CGContextSetLineDash(context, 0, length, 2);
-                CGContextStrokeRectWithWidth(context, CGRectInset(NSRectToCGRect(rect), 0,0), lineWidth);
+                CGContextStrokeRectWithWidth(context, rect, lineWidth);
             } else {
                 CGContextStrokeRectWithWidth(context, CGRectInset(NSRectToCGRect(rect), 0,0), lineWidth);
             }

+ 33 - 20
PDF Office/PDF Office/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Event.m

@@ -373,25 +373,38 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
             [menu insertItem:copyItem atIndex:0];
         }
     } else {
-        CPDFAnnotation *annotation = nil;        
-        for (CPDFAnnotation *tAnnotation in page.annotations) {
-            if ([tAnnotation hitTest:pagePoint]) {
-                annotation = tAnnotation;
-                break;
+        CPDFAnnotation *annotation = nil;
+        
+        if (([self toolMode] == CTextToolMode || [self toolMode] == CNoteToolMode || [self toolMode] == CFormToolMode || [self toolMode] == CSelfSignMode || [self toolMode] == CRedactToolMode) && [self hideNotes] == NO) {
+            
+            for (CPDFAnnotation *tAnnotation in page.annotations) {
+                if ([tAnnotation hitTest:pagePoint]) {
+                    annotation = tAnnotation;
+                    break;
+                }
+            }
+            
+            if (annotation && [annotation isKindOfClass:[CPDFWidgetAnnotation class]] ){
+                if(CFormToolMode == self.toolMode)
+                    annotation = nil;
+            }
+            
+            if(annotation) {
+                if(![self.activeAnnotations containsObject:annotation]) {
+                    [self updateActiveAnnotations:@[annotation]];
+                    [self setNeedsDisplayAnnotation:annotation];
+                }
             }
         }
-        
-        if (annotation && [annotation isKindOfClass:[CPDFWidgetAnnotation class]] ){
-            if(CFormToolMode == self.toolMode)
-                annotation = nil;
+                
+        if(annotation && [annotation isKindOfClass:[CPDFWidgetAnnotation class]] && [self toolMode] != CFormToolMode) {
+            annotation = nil;
+        } else if(annotation && [annotation isKindOfClass:[CPDFRedactAnnotation class]] && [self toolMode] != CRedactToolMode) {
+            annotation = nil;
+        } else if (annotation && [annotation isKindOfClass:[CPDFInkAnnotation class]] && [self annotationType] == CAnnotationTypeInk) {
+            annotation = nil;
         }
         
-        if(annotation) {
-            if(![self.activeAnnotations containsObject:annotation]) {
-                [self updateActiveAnnotations:@[annotation]];
-                [self setNeedsDisplayAnnotation:annotation];
-            }
-        }
 
         CPDFSelection *selection = [self creatImageCurrentSelectionForPoint:[event locationInPDFListView:self]];
         if(selection && CPDFSelectionTypeImage == [selection selectionType] && !self.activeAnnotation){
@@ -2589,15 +2602,15 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
                         startPoint = CGPointMake(startPoint.x - orgBounds.origin.x, startPoint.y - orgBounds.origin.y);
                         endPoint = CGPointMake(endPoint.x - orgBounds.origin.x, endPoint.y - orgBounds.origin.y);
                         
-                        startPoint  = CGPointMake(startPoint.x/orgBounds.size.width * newBounds.size.width, startPoint.y/orgBounds.size.height * newBounds.size.height);
-                        endPoint  = CGPointMake(endPoint.x/orgBounds.size.width * newBounds.size.width, endPoint.y/orgBounds.size.height * newBounds.size.height);
+                        startPoint  = CGPointMake((startPoint.x/orgBounds.size.width) * newBounds.size.width, (startPoint.y/orgBounds.size.height) * newBounds.size.height);
+                        endPoint  = CGPointMake((endPoint.x/orgBounds.size.width) * newBounds.size.width, (endPoint.y/orgBounds.size.height) * newBounds.size.height);
                         
-                        startPoint = CGPointMake(startPoint.x + orgBounds.origin.y, startPoint.y + orgBounds.origin.y);
-                        endPoint = CGPointMake(endPoint.x + orgBounds.origin.x, endPoint.y + orgBounds.origin.y);
+                        startPoint = CGPointMake(startPoint.x + newBounds.origin.x, startPoint.y + newBounds.origin.y);
+                        endPoint = CGPointMake(endPoint.x + newBounds.origin.x, endPoint.y + newBounds.origin.y);
                         
                         [(CPDFLineAnnotation *)dragAnnotation setStartPoint:startPoint];
                         [(CPDFLineAnnotation *)dragAnnotation setEndPoint:endPoint];
-                    } else {
+                    }
                         CGRect rect = CGRectMake(dragAnnotation.bounds.origin.x - orgBounds.origin.x, dragAnnotation.bounds.origin.y - orgBounds.origin.y, dragAnnotation.bounds.size.width, dragAnnotation.bounds.size.height);
                         
                         CGFloat minX = CGRectGetMinX(rect);