Browse Source

【注释】修复“Form签名注释点击后不能后续操作”

wanjun 10 months ago
parent
commit
268305d612

+ 4 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.h

@@ -15,7 +15,8 @@ typedef NS_ENUM(NSInteger, KMOpenPropertiesType) {
     KMOpenPropertiesType_Link,
     KMOpenPropertiesType_ListBox,
     KMOpenPropertiesType_ComboBox,
-    KMOpenPropertiesType_Button
+    KMOpenPropertiesType_Button,
+    KMOpenPropertiesType_FormSignatureClick
 };
 
 @class KMMainViewController;
@@ -40,6 +41,8 @@ typedef void(^PageDisplayReaderMode)(BOOL isReaderMode);
 
 @property (nonatomic, assign) IBOutlet KMMainViewController *mainController;
 
+@property (nonatomic, assign) BOOL isClickFormSignature;
+
 + (CGFloat)heightWithAnnotation:(CPDFAnnotation *)annotation;
 + (CGFloat)heightWithAnnotationMode:(CAnnotationType)annotationMode;
 

+ 21 - 6
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -297,12 +297,15 @@
         [self.view addSubview:vc.view];
         self.contentViewController = vc;
     } else if ([annotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
-        KMAnnotationGeneralViewController *vc = [[KMAnnotationGeneralViewController alloc] init];
-        vc.pdfview = self.pdfView;
-        vc.annotationModel = annotationModel;
-        vc.view.frame = [self viewControllerRect];
-        [self.view addSubview:vc.view];
-        self.contentViewController = vc;
+        if (!_isClickFormSignature) {
+            KMAnnotationGeneralViewController *vc = [[KMAnnotationGeneralViewController alloc] init];
+            vc.pdfview = self.pdfView;
+            vc.annotationModel = annotationModel;
+            vc.view.frame = [self viewControllerRect];
+            [self.view addSubview:vc.view];
+            self.contentViewController = vc;
+        }
+        _isClickFormSignature = NO;
     } else if ([annotation isKindOfClass:[CPDFLinkAnnotation class]]) {
         CPDFLinkAnnotation *linkAnnotation = annotations.firstObject;
         NSString *contents = nil;
@@ -698,6 +701,18 @@
                openPropertiesType == KMOpenPropertiesType_ComboBox ||
                openPropertiesType == KMOpenPropertiesType_Button) {
     
+    } else if (openPropertiesType == KMOpenPropertiesType_FormSignatureClick) {
+        self.contentViewController = nil;
+        self.titleLabel.stringValue = @"";
+        
+        CPDFAnnotationModel *annotationModel = [[CPDFAnnotationModel alloc] initWithPDFAnnotations:_annotations];
+        KMSignatureAnnotationViewController *vc = [[KMSignatureAnnotationViewController alloc] init];
+        vc.isClickSignatureList = YES;
+        vc.annotationModel = annotationModel;
+        vc.pdfView = self.pdfView;
+        vc.view.frame = [self viewControllerRect];
+        [self.view addSubview:vc.view];
+        self.contentViewController = vc;
     }
 }
 

+ 14 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/KMRightSideViewController.swift

@@ -51,6 +51,7 @@ class KMRightSideViewController: NSViewController,CipherTextViewDelegate {
         self.emptyVC_link = KMLinkAnnotationPropertyEmptyController()
         
         NotificationCenter.default.addObserver(self, selector: #selector(PDFViewActiveAnnotationDidChangeNotification(_:)), name: NSNotification.Name("KMPDFViewActiveAnnotationDidChangeNotification"), object: nil)
+        NotificationCenter.default.addObserver(self, selector: #selector(signatureSelectedNotification(_:)), name: NSNotification.Name("KMSignatureListSelectNotification"), object: nil)
     }
     
     public func reloadDataWithPDFView(pdfView:CPDFListView,isShow:Bool) {
@@ -333,7 +334,19 @@ class KMRightSideViewController: NSViewController,CipherTextViewDelegate {
 //            self.view.superview?.layer?.backgroundColor = NSColor(red: 0.988, green: 0.992, blue: 1, alpha: 1).cgColor
         }
     }
-
+    
+    
+    @objc func signatureSelectedNotification(_ notification: Notification) {
+        let editAnnotation: CPDFAnnotation = notification.object as! CPDFAnnotation
+        if self.mainController?.rightPanelIsOpen == false {
+            self.mainController?.toggleRightPane() 
+        }
+        self.annotationProperties.mainController = self.mainController
+        self.annotationProperties.isClickFormSignature = true;
+        self.annotationProperties.annotations = [editAnnotation]
+        self.annotationProperties.openPropertiesType = .formSignatureClick
+        self.annotationProperties.isEmptyAnnotation = false
+    }
 }
 
 extension KMRightSideViewController: KMEditImagePropertyViewControllerDelegate {

+ 3 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.h

@@ -14,6 +14,9 @@
 @property (nonatomic,strong) CPDFAnnotationModel *annotationModel;
 
 @property (nonatomic,strong) CPDFListView *pdfView;
+
+@property (nonatomic,assign) BOOL isClickSignatureList;
+
 @end
 
 

+ 34 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.m

@@ -353,6 +353,40 @@ KMSigntureViewItemDelegate>
 }
 
 - (void)collectionView:(NSCollectionView *)collectionView didSelectItemsAtIndexPaths:(NSSet<NSIndexPath *> *)indexPaths {
+    if (self.isClickSignatureList) {
+        NSInteger index = 0;
+        for (NSIndexPath *indexPath in self.collectionView.selectionIndexPaths) {
+            index = indexPath.item;
+        }
+        KMSignature *selectSignature = [self.signatures objectAtIndex:index];
+        
+        CPDFAnnotation *editAnnotation = (CPDFAnnotation *)self.annotationModel.annotations.firstObject;
+        CPDFPage *page = editAnnotation.page;
+        if ([editAnnotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
+            CPDFSignatureWidgetAnnotation * signatureaAnnotation = nil;
+            if ([editAnnotation isKindOfClass:[CPDFSignatureWidgetAnnotation class]]) {
+                signatureaAnnotation = (CPDFSignatureWidgetAnnotation *)editAnnotation;
+            } else {
+//                signatureaAnnotation= [[CPDFSignatureWidgetAnnotation alloc] initKMNoteWithBounds:editAnnotation.bounds document:self.pdfView.document];
+                signatureaAnnotation = [[CPDFSignatureWidgetAnnotation alloc] initWithKMNoteBounds:editAnnotation.bounds document:self.pdfView.document];
+                signatureaAnnotation.fieldName = [(CPDFSignatureWidgetAnnotation *)editAnnotation fieldName];
+                signatureaAnnotation.backgroundColor = [(CPDFSignatureWidgetAnnotation *)editAnnotation backgroundColor];
+                signatureaAnnotation.contents = editAnnotation.contents;
+                signatureaAnnotation.userName = editAnnotation.userName;
+                signatureaAnnotation.modificationDate = editAnnotation.modificationDate;
+            }
+            
+            [signatureaAnnotation signWithImage:selectSignature.pathsImage];
+            
+            [page removeAnnotation:editAnnotation];
+            [page addAnnotation:signatureaAnnotation];
+            [self.pdfView setNeedsDisplayAnnotationViewForPage:page];
+            [signatureaAnnotation setShouldDisplay:YES];
+        }
+        
+        return;
+    }
+    
     if (indexPaths.count == 1) {
         NSInteger index = 0;
         for (NSIndexPath *indexPath in self.collectionView.selectionIndexPaths) {

+ 1 - 1
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureAnnotationViewController.xib

@@ -62,7 +62,7 @@
                         </customView>
                         <button imageHugsTitle="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="19B-9D-nhz">
                             <rect key="frame" x="16" y="10" width="195" height="32"/>
-                            <buttonCell key="cell" type="bevel" title="Button" bezelStyle="regularSquare" image="KMImageNameUXIconBtnAddWhite" imagePosition="left" alignment="center" state="on" imageScaling="proportionallyDown" inset="2" id="nhi-wF-TuK" customClass="KMButtomCell">
+                            <buttonCell key="cell" type="bevel" title="Button" bezelStyle="regularSquare" image="KMImageNameUXIconBtnAddWhite" imagePosition="left" alignment="center" state="on" imageScaling="proportionallyDown" inset="2" id="nhi-wF-TuK" customClass="KMButtomCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                 <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
                                 <font key="font" metaFont="system"/>
                             </buttonCell>