Browse Source

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

niehaoyu 11 months ago
parent
commit
bf2a70d5fc

+ 1 - 1
PDF Office/PDF Master/Class/Batch/WindowController/VC/KMToolbarItemPopViewController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarItemPopViewController" customModule="PDF_Master" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarItemPopViewController" customModule="PDF_Reader_Pro" customModuleProvider="target">
             <connections>
                 <outlet property="toolbarHelpTipLabel" destination="Anw-6R-RbF" id="Ra3-8V-bZf"/>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>

+ 5 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/Signature/CPDFListSignatureAnnotation.swift

@@ -13,6 +13,7 @@ class CPDFListSignatureAnnotation: CPDFSignatureAnnotation {
     var _rotation: Int = 0
     var borderBounds: NSRect = NSRect.zero
     var pImage: NSImage?
+    var imageAlpha = 1.0
 
     override func keysForValuesToObserveForUndo() -> Set<AnyHashable>! {
         var mutableKeys: Set<AnyHashable>
@@ -26,6 +27,10 @@ class CPDFListSignatureAnnotation: CPDFSignatureAnnotation {
         return true
     }
     
+    func updateImage(newImg: NSImage)  {
+        
+    }
+    
     override func isResizable() -> Bool {
         return true
     }

+ 6 - 5
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListView.h

@@ -190,18 +190,19 @@ typedef NS_ENUM(NSInteger, KMPDFViewSplitMode) {
 @property (nonatomic, strong) CAShapeLayer *shapeLayerTopH;
 @property (nonatomic, strong) CAShapeLayer *shapeLayerBottomH;
 
-@property (nonatomic,assign) NSPoint lastAddAnnotationPoint;
+@property (nonatomic, assign) NSPoint lastAddAnnotationPoint;
 
 @property (nonatomic, assign) BOOL isCreatAnnotation;
 @property (nonatomic, assign) NSInteger toolBarCreateAnnotationMenuItem;
 
 @property (nonatomic, assign) BOOL isTakeSnapeSelectConetent;
 
-@property (nonatomic,assign) KMPDFViewMode viewMode;
-@property (nonatomic,assign) KMPDFViewSplitMode viewSplitMode;
+@property (nonatomic, assign) KMPDFViewMode viewMode;
+@property (nonatomic, assign) KMPDFViewSplitMode viewSplitMode;
 
-@property (nonatomic,strong) KMFormListMenuPopWindowController *listWindowController;
-@property (nonatomic,strong) NSTrackingArea *trackingArea;
+@property (nonatomic, strong) KMFormListMenuPopWindowController *listWindowController;
+@property (nonatomic, strong) NSTrackingArea *trackingArea;
+@property (nonatomic, strong) NSImage *originImage;
 
 - (CPDFAnnotation *)addAnnotationWithType:(CAnnotationType)annotationType selection:(CPDFSelection *)selection page:(CPDFPage *)page bounds:(NSRect)bounds;
 - (void)addAnnotationWithAnnotation:(CPDFAnnotation *)annotation toPage:(CPDFPage *)page;

+ 55 - 3
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFListViewExtension/CPDFListView+Extension.m

@@ -553,10 +553,62 @@ CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
 
 - (void)setSignatureAnnotation:(CPDFListSignatureAnnotation *)annotation forImageAlpha:(CGFloat)alpha {
     [[[self undoManager] prepareWithInvocationTarget:self] setSignatureAnnotation:annotation forImageAlpha:annotation.opacity];
-
+    
+    if (annotation.opacity > 0.99) {
+        self.originImage = annotation.pImage;
+    }
     annotation.opacity = alpha;
-    annotation.bounds = annotation.bounds;
-    [self setNeedsDisplay:YES];
+    NSImage *oldImage = self.originImage ?: [annotation.pImage copy];
+    NSImage *newImage = [self changeImage:oldImage alphaValue:alpha];
+    
+    self.stampObject = [[CStampSignatureObject alloc]initWithSignatureImage:newImage];
+//    annotation.stamp = stampObject;
+//    [annotation setImage:newImage];
+//    annotation.bounds = annotation.bounds;
+    [self updateAlphaAnnotation:annotation];
+}
+
+- (void)updateAlphaAnnotation:(CPDFListSignatureAnnotation *)annotation{
+    
+    NSImage * image = self.stampObject.signatureImage;
+    CPDFAnnotation *annotationNew = [[CPDFListSignatureAnnotation alloc] initWithDocument:self.document];
+    [(CPDFListSignatureAnnotation *)annotationNew setImage:image];
+    annotationNew.bounds = annotation.bounds;
+    annotationNew.opacity = annotation.opacity;
+    if(annotationNew) {
+        [annotationNew updateAppearanceStream];
+        [(CPDFListStampAnnotation *)annotationNew setBorderBoundsWithStamp:self.stampObject];
+        [self addAnnotation:annotationNew toPage:annotation.page];
+        [self updateActiveAnnotations:@[annotationNew]];
+        [self setNeedsDisplayAnnotation:annotationNew];
+    } else if(self.activeAnnotations.count >0) {
+        [self updateActiveAnnotations:@[]];
+        [self setNeedsDisplayAnnotationViewForPage:annotation.page];
+    }
+    
+    if (annotationNew) {
+        [self removeAnnotation:annotation];
+        self.stampObject = nil;
+        annotation = nil;
+        [self setNeedsDisplayAnnotation:annotation];
+    }
+}
+
+- (NSImage *)changeImage:(NSImage *)oldimage alphaValue:(CGFloat)alphaValue {
+    NSImage *newImage = [[NSImage alloc] initWithSize:[oldimage size]];
+    
+    [newImage lockFocus];
+    
+    [[NSGraphicsContext currentContext] saveGraphicsState];
+    CGContextSetAlpha([[NSGraphicsContext currentContext] CGContext], alphaValue);
+    
+    [oldimage drawAtPoint:NSMakePoint(0, 0) fromRect:NSMakeRect(0, 0, [oldimage size].width, [oldimage size].height) operation:NSCompositingOperationSourceOver fraction:alphaValue];
+    
+    [[NSGraphicsContext currentContext] restoreGraphicsState];
+    
+    [newImage unlockFocus];
+    
+    return newImage;
 }
 
 - (void)checkSpelling:(id)sender {

+ 17 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/Signature/KMSignatureWindowController.m

@@ -399,6 +399,23 @@ static NSMutableArray * recentlyFonts;
     self.applyButton.enabled = NO;
 }
 
+- (NSImage*)changeColor:(NSColor*)color oldImage:(NSImage *)oldImage {
+
+    NSImage *newImage = [oldImage copy];
+
+    [newImage lockFocus];
+
+    [color set];
+
+    NSRect imageRect=NSMakeRect(0, 0, oldImage.size.width, oldImage.size.height);
+
+    NSRectFillUsingOperation(imageRect, NSCompositingOperationSourceAtop);
+
+    [newImage unlockFocus];
+
+    return newImage;
+}
+
 - (void)applyButton_Click:(id)sender {
     KMSignature *signature = [[KMSignature alloc] init];
 

+ 1 - 0
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.swift

@@ -869,6 +869,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
             annotationModel?.setOpacity(CGFloat(opacity))
             opacityComboBox.stringValue = "\(Int(opacity * 100))%"
             updateAnnotation()
+            self.opacitySlider.floatValue = opacity
         }
     }
 

+ 12 - 12
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/StampList/KMAnnotationStampViewController.xib

@@ -92,7 +92,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="78" height="32"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0E3-F3-2Pg">
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="0E3-F3-2Pg">
                                 <rect key="frame" x="37" y="8" width="4" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" id="MOs-Eb-Gx1">
                                     <font key="font" usesAppearanceFont="YES"/>
@@ -114,7 +114,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="78" height="32"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HfE-48-3lV">
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="HfE-48-3lV">
                                 <rect key="frame" x="37" y="8" width="4" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" id="QTD-ci-jYJ">
                                     <font key="font" usesAppearanceFont="YES"/>
@@ -157,7 +157,7 @@
                         <rect key="frame" x="0.0" y="0.0" width="78" height="32"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="I93-Ww-ckj">
+                            <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="I93-Ww-ckj">
                                 <rect key="frame" x="37" y="8" width="4" height="16"/>
                                 <textFieldCell key="cell" lineBreakMode="clipping" id="dRl-PU-bWG">
                                     <font key="font" usesAppearanceFont="YES"/>
@@ -186,7 +186,7 @@
                                     </constraints>
                                     <imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="KMImageNameEmptyStamp" id="Wgu-2B-PFT"/>
                                 </imageView>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VYn-hy-KP4">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="VYn-hy-KP4">
                                     <rect key="frame" x="15" y="0.0" width="204" height="40"/>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="40" id="9pg-4b-Ee9"/>
@@ -198,7 +198,7 @@
                                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                                     </textFieldCell>
                                 </textField>
-                                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Mlh-u9-cE0">
+                                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Mlh-u9-cE0">
                                     <rect key="frame" x="55" y="48" width="124" height="20"/>
                                     <constraints>
                                         <constraint firstAttribute="height" constant="20" id="CVU-xa-gXa"/>
@@ -363,7 +363,7 @@
                         <action selector="dynamicStampButtonItemClicked_Author:" target="-2" id="QwQ-s3-kqw"/>
                     </connections>
                 </button>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nfe-06-8Hb">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="nfe-06-8Hb">
                     <rect key="frame" x="30" y="51" width="35" height="15"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="8fp-iH-M5S">
                         <font key="font" metaFont="cellTitle"/>
@@ -371,7 +371,7 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Cf3-ij-TW3">
+                <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Cf3-ij-TW3">
                     <rect key="frame" x="71" y="48" width="162" height="20"/>
                     <constraints>
                         <constraint firstAttribute="width" constant="162" id="InN-b8-goi"/>
@@ -383,7 +383,7 @@
                         <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
                     </textFieldCell>
                 </textField>
-                <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CiP-Jz-Xdn">
+                <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="CiP-Jz-Xdn">
                     <rect key="frame" x="30" y="18" width="35" height="15"/>
                     <textFieldCell key="cell" lineBreakMode="clipping" title="Label" id="VD2-sn-eiH">
                         <font key="font" metaFont="cellTitle"/>
@@ -397,7 +397,7 @@
                         <rect key="frame" x="1" y="1" width="160" height="20"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
-                            <comboBox verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wtD-Vt-js7" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                            <comboBox focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="wtD-Vt-js7" customClass="KMComboBox" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                 <rect key="frame" x="-1" y="-2" width="164" height="23"/>
                                 <comboBoxCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" drawsBackground="YES" buttonBordered="NO" completes="NO" numberOfVisibleItems="5" id="oR8-Eg-1Mn" customClass="KMStampComboBoxCell" customModule="PDF_Reader_Pro" customModuleProvider="target">
                                     <font key="font" metaFont="system"/>
@@ -538,7 +538,7 @@
                                     <rect key="frame" x="0.0" y="0.0" width="213" height="64"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tKZ-fa-8Ft">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="tKZ-fa-8Ft">
                                             <rect key="frame" x="-2" y="34" width="217" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="20" id="FJF-i6-gOD"/>
@@ -616,7 +616,7 @@
                                     <rect key="frame" x="0.0" y="0.0" width="213" height="326"/>
                                     <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                                     <subviews>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UsV-0m-nUC">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UsV-0m-nUC">
                                             <rect key="frame" x="-2" y="296" width="42" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="20" id="Qva-NE-D5a"/>
@@ -700,7 +700,7 @@
                                                 <action selector="opacitySliderAction:" target="-2" id="mik-d8-oIH"/>
                                             </connections>
                                         </slider>
-                                        <textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Dl7-N2-sZY">
+                                        <textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Dl7-N2-sZY">
                                             <rect key="frame" x="-2" y="32" width="42" height="20"/>
                                             <constraints>
                                                 <constraint firstAttribute="height" constant="20" id="0vB-EP-csS"/>