|
@@ -28,13 +28,14 @@ struct KMPDFAnnotationSignatureType: OptionSet {
|
|
let KMPDFDynamicStampDateStyleKey1 = "km_pdfview_dynamic_stamp_date_style"
|
|
let KMPDFDynamicStampDateStyleKey1 = "km_pdfview_dynamic_stamp_date_style"
|
|
let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
|
|
|
|
-@available(macOS 13.0, *)
|
|
|
|
-@objcMembers class KMAnnotationStampViewController: NSViewController, NSTextViewDelegate, NSComboBoxDelegate {
|
|
|
|
|
|
+@objcMembers class KMAnnotationStampViewController: NSViewController, NSTextViewDelegate, NSComboBoxDelegate, NSTableViewDelegate, NSTableViewDataSource {
|
|
|
|
|
|
- var _annotations: [CPDFAnnotation]?
|
|
|
|
weak var pdfView: CPDFListView?
|
|
weak var pdfView: CPDFListView?
|
|
var isClickSignatureList: Bool = false
|
|
var isClickSignatureList: Bool = false
|
|
-
|
|
|
|
|
|
+ var isContinuousAddStamp: Bool = false
|
|
|
|
+ var isImageStamp: Bool = false
|
|
|
|
+ var annotationModel: CPDFAnnotationModel?
|
|
|
|
+
|
|
@IBOutlet weak var mainViewBox: NSBox!
|
|
@IBOutlet weak var mainViewBox: NSBox!
|
|
|
|
|
|
@IBOutlet weak var createStampView: NSView!
|
|
@IBOutlet weak var createStampView: NSView!
|
|
@@ -100,16 +101,14 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
@IBOutlet weak var leftImageView: NSImageView!
|
|
@IBOutlet weak var leftImageView: NSImageView!
|
|
@IBOutlet weak var rightImageView: NSImageView!
|
|
@IBOutlet weak var rightImageView: NSImageView!
|
|
|
|
|
|
- var _annotation: KMAnnotationStamp!
|
|
|
|
-
|
|
|
|
var _stampType: KMCreateStampType!
|
|
var _stampType: KMCreateStampType!
|
|
|
|
|
|
var annotationStampType: KMAnnotationStampCreateType!
|
|
var annotationStampType: KMAnnotationStampCreateType!
|
|
|
|
|
|
- var selectedStamp: KMAnnotationStamp!
|
|
|
|
- var standardStamps: [KMAnnotationStamp]!
|
|
|
|
- var customStamps: [KMAnnotationStamp]!
|
|
|
|
- var dynamicStamps: [KMAnnotationStamp]!
|
|
|
|
|
|
+ var selectedStamp: CStampObject!
|
|
|
|
+ var standardStamps: [CStampObject]!
|
|
|
|
+ var customStamps: [CStampObject]!
|
|
|
|
+ var dynamicStamps: [CStampObject]!
|
|
var dynamicStampNeedsAuthor: Bool!
|
|
var dynamicStampNeedsAuthor: Bool!
|
|
var dateFormatterString: String!
|
|
var dateFormatterString: String!
|
|
var dateStyleArray: [String]!
|
|
var dateStyleArray: [String]!
|
|
@@ -125,12 +124,12 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
NotificationCenter.default.removeObserver(self)
|
|
NotificationCenter.default.removeObserver(self)
|
|
DistributedNotificationCenter.default.removeObserver(self)
|
|
DistributedNotificationCenter.default.removeObserver(self)
|
|
|
|
|
|
- // Remove observers for specific key paths
|
|
|
|
- let keys = ["string", "rotation", "imageAlpha"]
|
|
|
|
- for key in keys {
|
|
|
|
- self.annotation.removeObserver(self, forKeyPath: key)
|
|
|
|
|
|
+ if ((annotationModel?.annotation) != nil) && annotationModel?.annotations.count == 1 {
|
|
|
|
+ let keys = ["string", "rotation", "imageAlpha"]
|
|
|
|
+ for key in keys {
|
|
|
|
+ self.annotation.removeObserver(self, forKeyPath: key)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
dateComboBox.delegate = nil
|
|
dateComboBox.delegate = nil
|
|
contentTextView.delegate = nil
|
|
contentTextView.delegate = nil
|
|
|
|
|
|
@@ -147,50 +146,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
super.viewDidLoad()
|
|
super.viewDidLoad()
|
|
// Do view setup here.
|
|
// Do view setup here.
|
|
|
|
|
|
- if pdfView!.isCreatAnnotation {
|
|
|
|
- mainViewBox.contentView = createStampView
|
|
|
|
- noCustomStampLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
|
- leftImageView.wantsLayer = true
|
|
|
|
- rightImageView.wantsLayer = true
|
|
|
|
- leftImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
|
|
|
|
- rightImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
|
|
|
|
-
|
|
|
|
- if let image = annotation.image {
|
|
|
|
- annotationStampType = .signature
|
|
|
|
-
|
|
|
|
- emptyImageView.image = NSImage(named: KMImageNameEmptySign)
|
|
|
|
- emptyLabel.stringValue = NSLocalizedString("Click \"New Signature\" button below to create a signature.", comment: "")
|
|
|
|
- emptyLabel.textColor = KMAppearance.Layout.h2Color()
|
|
|
|
- noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
|
|
|
|
- initCreateSignatureView()
|
|
|
|
- } else {
|
|
|
|
- dateComboBox.type = .none
|
|
|
|
- dateComboBox.comboxRect = dateComboBox.bounds
|
|
|
|
-
|
|
|
|
- authorTextField.backgroundColor = KMAppearance.Layout.l1Color()
|
|
|
|
- authorTextField.wantsLayer = true
|
|
|
|
- dateComboBox.wantsLayer = true
|
|
|
|
- authorTextField.layer?.borderWidth = 1.0
|
|
|
|
- authorTextField.layer?.cornerRadius = 1.0
|
|
|
|
-
|
|
|
|
- dateBox.borderColor = KMAppearance.Interactive.s0Color()
|
|
|
|
- dateBox.fillColor = KMAppearance.Layout.l1Color()
|
|
|
|
-
|
|
|
|
- annotationStampType = .type_default
|
|
|
|
-
|
|
|
|
- emptyImageView.image = NSImage(named: KMImageNameEmptyStamp)
|
|
|
|
- initCreateStampView()
|
|
|
|
-
|
|
|
|
- switch pdfView!.toolBarCreateAnnotationMenuItem {
|
|
|
|
- case Int(KMCreateStampType.standard.rawValue):
|
|
|
|
- stampType = .standard
|
|
|
|
- case Int(KMCreateStampType.custom.rawValue):
|
|
|
|
- stampType = .custom
|
|
|
|
- case Int(KMCreateStampType.dynamic.rawValue):
|
|
|
|
- stampType = .dynamic
|
|
|
|
- default: break
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if annotationModel?.annotations != nil {
|
|
|
|
+ mainViewBox.contentView = clickStampView
|
|
|
|
+ initClickStampView()
|
|
} else {
|
|
} else {
|
|
if isClickSignatureList {
|
|
if isClickSignatureList {
|
|
mainViewBox.contentView = createStampView
|
|
mainViewBox.contentView = createStampView
|
|
@@ -204,8 +162,49 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
|
|
noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
|
|
initCreateSignatureView()
|
|
initCreateSignatureView()
|
|
} else {
|
|
} else {
|
|
- mainViewBox.contentView = clickStampView
|
|
|
|
- initClickStampView()
|
|
|
|
|
|
+ mainViewBox.contentView = createStampView
|
|
|
|
+ noCustomStampLabel.textColor = KMAppearance.Layout.h1Color()
|
|
|
|
+ leftImageView.wantsLayer = true
|
|
|
|
+ rightImageView.wantsLayer = true
|
|
|
|
+ leftImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
|
|
|
|
+ rightImageView.layer?.backgroundColor = KMAppearance.Layout.b15_1Color().cgColor
|
|
|
|
+
|
|
|
|
+ if isImageStamp {
|
|
|
|
+ annotationStampType = .signature
|
|
|
|
+
|
|
|
|
+ emptyImageView.image = NSImage(named: KMImageNameEmptySign)
|
|
|
|
+ emptyLabel.stringValue = NSLocalizedString("Click \"New Signature\" button below to create a signature.", comment: "")
|
|
|
|
+ emptyLabel.textColor = KMAppearance.Layout.h2Color()
|
|
|
|
+ noCustomStampLabel.stringValue = NSLocalizedString("No Signatures", comment: "")
|
|
|
|
+ initCreateSignatureView()
|
|
|
|
+ } else {
|
|
|
|
+ dateComboBox.type = .none
|
|
|
|
+ dateComboBox.comboxRect = dateComboBox.bounds
|
|
|
|
+
|
|
|
|
+ authorTextField.backgroundColor = KMAppearance.Layout.l1Color()
|
|
|
|
+ authorTextField.wantsLayer = true
|
|
|
|
+ dateComboBox.wantsLayer = true
|
|
|
|
+ authorTextField.layer?.borderWidth = 1.0
|
|
|
|
+ authorTextField.layer?.cornerRadius = 1.0
|
|
|
|
+
|
|
|
|
+ dateBox.borderColor = KMAppearance.Interactive.s0Color()
|
|
|
|
+ dateBox.fillColor = KMAppearance.Layout.l1Color()
|
|
|
|
+
|
|
|
|
+ annotationStampType = .type_default
|
|
|
|
+
|
|
|
|
+ emptyImageView.image = NSImage(named: KMImageNameEmptyStamp)
|
|
|
|
+ initCreateStampView()
|
|
|
|
+
|
|
|
|
+ switch pdfView!.toolBarCreateAnnotationMenuItem {
|
|
|
|
+ case Int(KMCreateStampType.standard.rawValue):
|
|
|
|
+ stampType = .standard
|
|
|
|
+ case Int(KMCreateStampType.custom.rawValue):
|
|
|
|
+ stampType = .custom
|
|
|
|
+ case Int(KMCreateStampType.dynamic.rawValue):
|
|
|
|
+ stampType = .dynamic
|
|
|
|
+ default: break
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -223,32 +222,15 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
|
|
|
|
// MARK: Set & Get
|
|
// MARK: Set & Get
|
|
|
|
|
|
- var annotations: [CPDFAnnotation] {
|
|
|
|
- set {
|
|
|
|
- _annotations = newValue
|
|
|
|
-
|
|
|
|
- _annotation = (_annotations?.first as? KMAnnotationStamp) ?? KMAnnotationStamp()
|
|
|
|
- }
|
|
|
|
|
|
+ var annotations: [KMAnnotationStamp] {
|
|
get {
|
|
get {
|
|
- return _annotations!
|
|
|
|
|
|
+ return annotationModel?.annotations as! [KMAnnotationStamp]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
var annotation: KMAnnotationStamp {
|
|
var annotation: KMAnnotationStamp {
|
|
- set {
|
|
|
|
- if _annotation.isEqual(newValue) {
|
|
|
|
- let keys = ["string", "rotation", "imageAlpha"]
|
|
|
|
- for key in keys {
|
|
|
|
- _annotation.removeObserver(self, forKeyPath: key)
|
|
|
|
- }
|
|
|
|
- _annotation = newValue
|
|
|
|
- for key in keys {
|
|
|
|
- _annotation.addObserver(self, forKeyPath: key, options: [.new, .old], context: nil)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
get {
|
|
get {
|
|
- return _annotation
|
|
|
|
|
|
+ return annotationModel?.annotation as! KMAnnotationStamp
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -405,7 +387,12 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
annotationLabel.stringValue = NSLocalizedString("Note", comment: "")
|
|
annotationLabel.stringValue = NSLocalizedString("Note", comment: "")
|
|
annotationLabel.textColor = KMAppearance.Layout.h0Color()
|
|
annotationLabel.textColor = KMAppearance.Layout.h0Color()
|
|
|
|
|
|
- let opacity = annotation.imageAlpha
|
|
|
|
|
|
+ var opacity = 1.0
|
|
|
|
+ if annotationModel?.annotations != nil {
|
|
|
|
+ if annotation is KMAnnotationStamp {
|
|
|
|
+ opacity = Double((annotation as! KMAnnotationStamp).imageAlpha)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
opacitySlider.floatValue = Float(opacity)
|
|
opacitySlider.floatValue = Float(opacity)
|
|
opacityComboBox.stringValue = String(format: "%d%%", Int(opacity * 100))
|
|
opacityComboBox.stringValue = String(format: "%d%%", Int(opacity * 100))
|
|
|
|
|
|
@@ -454,16 +441,20 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
}
|
|
}
|
|
|
|
|
|
contentTextView.wantsLayer = true
|
|
contentTextView.wantsLayer = true
|
|
- contentTextView.string = annotation.contentStr
|
|
|
|
|
|
+ if annotationModel?.annotations != nil {
|
|
|
|
+ contentTextView.string = annotation.contentStr
|
|
|
|
+ }
|
|
contentTextView.textColor = NSColor.labelColor
|
|
contentTextView.textColor = NSColor.labelColor
|
|
contentTextView.layer?.borderWidth = 0.5
|
|
contentTextView.layer?.borderWidth = 0.5
|
|
contentTextView.layer?.cornerRadius = 1.0
|
|
contentTextView.layer?.cornerRadius = 1.0
|
|
contentTextView.delegate = self
|
|
contentTextView.delegate = self
|
|
contentTextView.isEditable = false
|
|
contentTextView.isEditable = false
|
|
|
|
|
|
- sampleImageView.image = annotationImage()
|
|
|
|
|
|
+ sampleImageView.image = annotationModel?.annotationImage
|
|
|
|
|
|
- opacityBox.isHidden = annotation.image == nil
|
|
|
|
|
|
+ if annotationModel?.annotations != nil {
|
|
|
|
+ opacityBox.isHidden = annotation.image == nil
|
|
|
|
+ }
|
|
opacityBoxTopLayoutConstraint.constant = opacityBox.isHidden ? 16 : 96
|
|
opacityBoxTopLayoutConstraint.constant = opacityBox.isHidden ? 16 : 96
|
|
|
|
|
|
updateViewColor()
|
|
updateViewColor()
|
|
@@ -492,6 +483,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
}
|
|
}
|
|
|
|
|
|
func createStandardTypeStamp() {
|
|
func createStandardTypeStamp() {
|
|
|
|
+ createStampTableView.delegate = self
|
|
|
|
+ createStampTableView.dataSource = self
|
|
|
|
+
|
|
leftImageView.isHidden = true
|
|
leftImageView.isHidden = true
|
|
rightImageView.isHidden = false
|
|
rightImageView.isHidden = false
|
|
|
|
|
|
@@ -507,7 +501,6 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
footBox.isHidden = true
|
|
footBox.isHidden = true
|
|
|
|
|
|
loadStandardStamps()
|
|
loadStandardStamps()
|
|
-
|
|
|
|
createStampTableView.reloadData()
|
|
createStampTableView.reloadData()
|
|
}
|
|
}
|
|
|
|
|
|
@@ -604,13 +597,13 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
if standardStamps != nil {
|
|
if standardStamps != nil {
|
|
standardStamps.removeAll()
|
|
standardStamps.removeAll()
|
|
} else {
|
|
} else {
|
|
- self.standardStamps = []
|
|
|
|
|
|
+ standardStamps = []
|
|
}
|
|
}
|
|
|
|
|
|
- for i in 0..<28 {
|
|
|
|
- let stamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- stamp.customStampType = KMAnnotationStampType(rawValue: i)
|
|
|
|
- self.standardStamps?.append(stamp)
|
|
|
|
|
|
+ KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
|
|
|
|
+ if (obj.stampCategoryType == .standard) {
|
|
|
|
+ standardStamps?.append(obj)
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -618,22 +611,15 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
if self.customStamps != nil {
|
|
if self.customStamps != nil {
|
|
customStamps.removeAll()
|
|
customStamps.removeAll()
|
|
} else {
|
|
} else {
|
|
- self.customStamps = []
|
|
|
|
|
|
+ customStamps = []
|
|
}
|
|
}
|
|
|
|
|
|
- for s in KMStampManagerNew.shareManager.stamps {
|
|
|
|
- let stamp = KMAnnotationStamp(withBounds: NSRect(x: 0, y: 0, width: 480, height: 90))
|
|
|
|
-
|
|
|
|
- if s.isImageStamp {
|
|
|
|
- stamp.image = NSImage(contentsOfFile: s.imagePath)
|
|
|
|
- } else {
|
|
|
|
- stamp.setCustomStampString(s.string, dateString: s.subString)
|
|
|
|
- stamp.stampColor = KMAnnotationStampColorType(rawValue: s.color)
|
|
|
|
|
|
+ KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
|
|
|
|
+ if (obj.stampCategoryType == .text || obj.stampCategoryType == .image) {
|
|
|
|
+ self.customStamps?.append(obj)
|
|
}
|
|
}
|
|
-
|
|
|
|
- self.customStamps?.append(stamp)
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if let customStamps = self.customStamps, customStamps.count > 0 {
|
|
if let customStamps = self.customStamps, customStamps.count > 0 {
|
|
reloadCustomEmptyState(false)
|
|
reloadCustomEmptyState(false)
|
|
} else {
|
|
} else {
|
|
@@ -648,35 +634,11 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
dynamicStamps.removeAll()
|
|
dynamicStamps.removeAll()
|
|
}
|
|
}
|
|
|
|
|
|
- let tRevisedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- tRevisedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
|
|
|
|
- tRevisedStamp.setCustomStampString("REVISED", dateString: tRevisedStamp.dateString)
|
|
|
|
- tRevisedStamp.stampColor = .RedColor
|
|
|
|
- dynamicStamps.append(tRevisedStamp)
|
|
|
|
-
|
|
|
|
- let tReviewedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- tReviewedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
|
|
|
|
- tReviewedStamp.setCustomStampString("REVIEWED", dateString: tReviewedStamp.dateString)
|
|
|
|
- tRevisedStamp.stampColor = .GreenColor
|
|
|
|
- dynamicStamps.append(tReviewedStamp)
|
|
|
|
-
|
|
|
|
- let tReceivedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- tReceivedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
|
|
|
|
- tReceivedStamp.setCustomStampString("RECEIVED", dateString: tReceivedStamp.dateString)
|
|
|
|
- tReceivedStamp.stampColor = .GreenColor
|
|
|
|
- dynamicStamps.append(tReceivedStamp)
|
|
|
|
-
|
|
|
|
- let tApprovedStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- tApprovedStamp.dateString = setDynamicStampDateString(withDateStyle: dateFormatterString)
|
|
|
|
- tApprovedStamp.setCustomStampString("APPROVED", dateString: tApprovedStamp.dateString)
|
|
|
|
- tApprovedStamp.stampColor = .GreenColor
|
|
|
|
- dynamicStamps.append(tApprovedStamp)
|
|
|
|
-
|
|
|
|
- let tConfidentialStamp = KMAnnotationStamp(withBounds: NSMakeRect(0, 0, 480, 90))
|
|
|
|
- tConfidentialStamp.needExchangeFontSize = true
|
|
|
|
- tConfidentialStamp.setCustomStampString(dynamicStampNeedsAuthor ? authorTextField.stringValue : "", dateString: "CONFIDENTIAL")
|
|
|
|
- tConfidentialStamp.stampColor = .RedColor
|
|
|
|
- dynamicStamps.append(tConfidentialStamp)
|
|
|
|
|
|
+ KMStampManager.defaultManager.stamps.enumerated().forEach { (index, obj) in
|
|
|
|
+ if (obj.stampCategoryType == CPDFStampType.init(rawValue: CPDFStampTypeDynamic)!) {
|
|
|
|
+ dynamicStamps?.append(obj)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func setDynamicStampDateString(withDateStyle dateStyleString: String) -> String {
|
|
func setDynamicStampDateString(withDateStyle dateStyleString: String) -> String {
|
|
@@ -800,7 +762,9 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
imageStampButtonLayer.isHidden = true
|
|
imageStampButtonLayer.isHidden = true
|
|
textStampButtonLayer.isHidden = true
|
|
textStampButtonLayer.isHidden = true
|
|
|
|
|
|
- addButtonLayer.isHidden = true
|
|
|
|
|
|
+ if addButtonLayer != nil {
|
|
|
|
+ addButtonLayer.isHidden = true
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
func isDamageImage(_ image: NSImage, imagePath path: String) -> Bool {
|
|
func isDamageImage(_ image: NSImage, imagePath path: String) -> Bool {
|
|
@@ -906,14 +870,14 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
@IBAction func opacitySliderAction(_ sender: Any) {
|
|
@IBAction func opacitySliderAction(_ sender: Any) {
|
|
for tAnnotation in self.annotations {
|
|
for tAnnotation in self.annotations {
|
|
let opacity = self.opacitySlider.floatValue
|
|
let opacity = self.opacitySlider.floatValue
|
|
- self.pdfView?.setStampAnnotation((tAnnotation as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
|
|
|
|
|
|
+ self.pdfView?.setStampAnnotation((tAnnotation), forImageAlpha: CGFloat(opacity))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@IBAction func opacityComboBoxAction(_ sender: Any) {
|
|
@IBAction func opacityComboBoxAction(_ sender: Any) {
|
|
for tAnnotation in self.annotations {
|
|
for tAnnotation in self.annotations {
|
|
let opacity = CGFloat(self.opacityComboBox.intValue) / 100
|
|
let opacity = CGFloat(self.opacityComboBox.intValue) / 100
|
|
- self.pdfView?.setStampAnnotation((tAnnotation as! KMAnnotationStamp), forImageAlpha: CGFloat(opacity))
|
|
|
|
|
|
+ self.pdfView?.setStampAnnotation((tAnnotation ), forImageAlpha: CGFloat(opacity))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -978,28 +942,17 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
- if let annotationImage = self.annotation.image {
|
|
|
|
- let selectSignature: KMSignature = self.signatures[index] as! KMSignature
|
|
|
|
- if selectSignature != nil {
|
|
|
|
- self.pdfView?.isCreatAnnotation = false
|
|
|
|
- self.pdfView?.addAnnotation(with: selectSignature)
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- switch stampType {
|
|
|
|
- case .standard:
|
|
|
|
- self.selectedStamp = self.standardStamps[index]
|
|
|
|
- case .dynamic:
|
|
|
|
- self.loadDynamicStamps()
|
|
|
|
- self.selectedStamp = self.dynamicStamps[index]
|
|
|
|
- case .custom:
|
|
|
|
- self.selectedStamp = self.customStamps[index]
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if let selectedStamp = self.selectedStamp {
|
|
|
|
- pdfView?.isCreatAnnotation = false
|
|
|
|
- pdfView?.addAnnotation(with: selectedStamp)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ var stampLists: [CStampObject] = []
|
|
|
|
+ switch stampType {
|
|
|
|
+ case .standard:
|
|
|
|
+ stampLists = standardStamps
|
|
|
|
+ case .dynamic:
|
|
|
|
+ stampLists = dynamicStamps
|
|
|
|
+ case .custom:
|
|
|
|
+ stampLists = customStamps
|
|
|
|
+ }
|
|
|
|
+ let stamp: CStampObject = stampLists[index]
|
|
|
|
+ pdfView?.setAddStamp(stamp, keepToolModel: false)
|
|
}
|
|
}
|
|
|
|
|
|
@IBAction func addButtonAction(_ sender: NSButton) {
|
|
@IBAction func addButtonAction(_ sender: NSButton) {
|
|
@@ -1052,7 +1005,11 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
if filePath.pathExtension.lowercased() == "pdf" {
|
|
if filePath.pathExtension.lowercased() == "pdf" {
|
|
if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
|
|
if let pdf = CPDFDocument(url: url), pdf.isEncrypted {
|
|
let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
|
|
let passwordWC = PasswordWindowController(windowNibName: "PasswordWindowController")
|
|
- passwordWC.fileURL = URL(filePath: filePath)
|
|
|
|
|
|
+ if #available(macOS 13.0, *) {
|
|
|
|
+ passwordWC.fileURL = URL(filePath: filePath)
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ }
|
|
passwordWC.beginSheetModal(for: myself.view.window!) { [weak self] password in
|
|
passwordWC.beginSheetModal(for: myself.view.window!) { [weak self] password in
|
|
self!.addImageStamp(withSecurityPDFFilePath: filePath, password: password, removeBGColor: (accessoryCtr.selectedButton.state == .on))
|
|
self!.addImageStamp(withSecurityPDFFilePath: filePath, password: password, removeBGColor: (accessoryCtr.selectedButton.state == .on))
|
|
}
|
|
}
|
|
@@ -1229,7 +1186,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
}
|
|
}
|
|
|
|
|
|
if annotationStampType == .type_default {
|
|
if annotationStampType == .type_default {
|
|
- var stamp: KMAnnotationStamp?
|
|
|
|
|
|
+ var stamp: CStampObject?
|
|
switch stampType {
|
|
switch stampType {
|
|
case .standard:
|
|
case .standard:
|
|
stamp = standardStamps[row]
|
|
stamp = standardStamps[row]
|
|
@@ -1258,7 +1215,7 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- cellView.sampleImageButton.image = stamp?.stampImage()
|
|
|
|
|
|
+ cellView.sampleImageButton.image = stamp?.stampPreImage()
|
|
cellView.closeButton.tag = row
|
|
cellView.closeButton.tag = row
|
|
cellView.closeButton.target = self
|
|
cellView.closeButton.target = self
|
|
cellView.closeButton.action = #selector(tableCellCloseButton_Click(_:))
|
|
cellView.closeButton.action = #selector(tableCellCloseButton_Click(_:))
|
|
@@ -1300,24 +1257,17 @@ let KMPDFDynamicStampNeedAuthorKey1 = "km_pdfview_dynamic_stamp_need_author"
|
|
}
|
|
}
|
|
|
|
|
|
@objc func tableViewSelectionDidChange(_ notification: Notification) {
|
|
@objc func tableViewSelectionDidChange(_ notification: Notification) {
|
|
- if let image = annotation.image {
|
|
|
|
- let selectSignature = self.signatures[createStampTableView.selectedRow] as! KMSignature
|
|
|
|
- pdfView!.isCreatAnnotation = false
|
|
|
|
- pdfView!.addAnnotation(with: selectSignature)
|
|
|
|
- } else {
|
|
|
|
- if stampType == .standard {
|
|
|
|
- selectedStamp = standardStamps[createStampTableView.selectedRow]
|
|
|
|
- } else if stampType == .dynamic {
|
|
|
|
- loadDynamicStamps()
|
|
|
|
- selectedStamp = self.dynamicStamps[createStampTableView.selectedRow]
|
|
|
|
- } else if stampType == .custom {
|
|
|
|
- selectedStamp = self.customStamps[createStampTableView.selectedRow]
|
|
|
|
- }
|
|
|
|
- if let selectedStamp = self.selectedStamp {
|
|
|
|
- pdfView!.isCreatAnnotation = false
|
|
|
|
- pdfView!.addAnnotation(with: selectedStamp)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ var stampLists: [CStampObject] = []
|
|
|
|
+ switch stampType {
|
|
|
|
+ case .standard:
|
|
|
|
+ stampLists = standardStamps
|
|
|
|
+ case .dynamic:
|
|
|
|
+ stampLists = dynamicStamps
|
|
|
|
+ case .custom:
|
|
|
|
+ stampLists = customStamps
|
|
|
|
+ }
|
|
|
|
+ let stamp: CStampObject = stampLists[createStampTableView.selectedRow]
|
|
|
|
+ pdfView?.setAddStamp(stamp, keepToolModel: false)
|
|
}
|
|
}
|
|
|
|
|
|
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|
|
func tableView(_ tableView: NSTableView, rowViewForRow row: Int) -> NSTableRowView? {
|