// // KMRightSideController.swift // PDF Reader Pro // // Created by Niehaoyu on 2024/11/12. // import Cocoa import KMComponentLibrary @objc protocol KMRightSideControllerDelegate: AnyObject { @objc optional func kmRightSideControllerDidContendVCUpdated(_ controller: KMRightSideController) //OCR @objc func kmRightSideControllerOCRShowTypeChange(_ controller: KMRightSideController, _ type: KMOCRShowType) @objc func kmRightSideControllerOCRDoneAction(_ controller: KMRightSideController, _ model: KMOCRModel) @objc func kmRightSideControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) @objc func kmRightSideControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) @objc func kmRightSideControllerShowMeasureSetting(_ controller: KMRightSideController) } class KMRightSideController: NSViewController { @IBOutlet var contendView: NSView! @IBOutlet var contendLeftDivider: ComponentDivider! @IBOutlet var headerBGView: NSView! @IBOutlet var titleLabel: NSTextField! @IBOutlet var headerRightButton: ComponentButton! @IBOutlet var infoContendView: NSView! @IBOutlet var infoContendTopConst: NSLayoutConstraint! @IBOutlet var infoScrollView: KMScrollView! @IBOutlet var emptyView: ComponentEmpty! var pdfView: CPDFListView? var viewManager: KMPDFViewManager? //Controller //Markup var highlight_Controller: KMHighlightController? var note_Controller: KMNoteController? var pen_Controller: KMPenController? var eraser_Controller: KMEraserController? var rectangle_Controller: KMRectangleController? var line_Controller: KMLineController? var freeText_Controller: KMTextBoxController? var stamplist_Controller: KMStampListController? var stamp_Controller: KMStampController? var signature_Controller: KMSignatureController? var signatureList_Controller: KMSignatureListController? var measure_Controller: KMMeasureController? //Edit var edit_textController: KMEditPDFTextPropertyViewController? var edit_imageController: KMEditImageController? var edit_linkController: KMLinkViewController? var edit_cropController: KMCropPropertyController? var edit_alignmentController: KMNAlignmentController? //Form var form_fieldController: FormsTextFieldController? var form_checkBoxController: FormsCheckBoxController? var form_radioController: FormsRadioController? var form_listController: FormsListController? var form_buttonController: FormsButtonController? var form_digitalSignController: FormsDigitalSignController? //Fill var fill_tickController: FillTickController? var fill_dateController: FillDateController? // //OCR var tool_OCRController: KMOCRController? var contentViewController: NSViewController? weak open var delegate: KMRightSideControllerDelegate? //MARK: - func override func viewDidLoad() { super.viewDidLoad() // Do view setup here. setupUI() setupContentController() } //MARK: - Get func getValidAnnotations() -> [CPDFAnnotation] { return [] } //MARK: - Set func setupUI() { contendView.wantsLayer = true contendView.layer?.backgroundColor = ComponentLibrary.shared.getComponentColorFromKey("colorBg/layout-middle").cgColor contendLeftDivider.properties = ComponentDividerProperty(type: .vertical) titleLabel.textColor = ComponentLibrary.shared.getComponentColorFromKey("colorText/2") titleLabel.font = ComponentLibrary.shared.getFontFromKey("mac/body-m-bold") emptyView.properties = ComponentEmptyProperty(emptyType: .noWatermark, text: KMLocalizedString("No identical attributes"), subText: "") } func updateTitleLabel() { let subToolMode = viewManager?.subToolMode ?? .None let annotations: [CPDFAnnotation] = self.pdfView?.activeAnnotations as? [CPDFAnnotation] ?? [] var firstAnnotation: CPDFAnnotation? if let firstObject = annotations.first { firstAnnotation = firstObject } titleLabel.stringValue = "" if contentViewController is KMHighlightController { titleLabel.stringValue = KMLocalizedString("Highlight") if let annotation = firstAnnotation, annotation is CPDFMarkupAnnotation { let markupAnnotation = firstAnnotation as! CPDFMarkupAnnotation if markupAnnotation.markupType() == .underline { titleLabel.stringValue = KMLocalizedString("Underline") } else if markupAnnotation.markupType() == .squiggly { titleLabel.stringValue = KMLocalizedString("Wavyline") } else if markupAnnotation.markupType() == .strikeOut { titleLabel.stringValue = KMLocalizedString("Strikethrough") } } else { if viewManager?.subToolMode == .Underline { titleLabel.stringValue = KMLocalizedString("Underline") } else if viewManager?.subToolMode == .Waveline { titleLabel.stringValue = KMLocalizedString("Wavyline") } else if viewManager?.subToolMode == .Strikethrough { titleLabel.stringValue = KMLocalizedString("Strikethrough") } } } else if (contentViewController is KMNoteController) { titleLabel.stringValue = KMLocalizedString("Note") } else if (contentViewController is KMPenController) { titleLabel.stringValue = KMLocalizedString("Pen") } else if (contentViewController is KMEraserController) { titleLabel.stringValue = KMLocalizedString("Eraser") } else if (contentViewController is KMLineController) { if let annotation = firstAnnotation, annotation is CPDFLineAnnotation { let lineAnnotation = firstAnnotation as! CPDFLineAnnotation if lineAnnotation.type == "Line" { titleLabel.stringValue = KMLocalizedString("Line") } else if lineAnnotation.type == "Arrow" { titleLabel.stringValue = KMLocalizedString("Arrow") } } else if subToolMode == .Arrow { titleLabel.stringValue = KMLocalizedString("Arrow") } else if subToolMode == .Line { titleLabel.stringValue = KMLocalizedString("Line") } } else if (contentViewController is KMRectangleController) { if let annotation = firstAnnotation, annotation is CPDFSquareAnnotation { titleLabel.stringValue = KMLocalizedString("Rectangle") } else if let annotation = firstAnnotation, annotation is CPDFCircleAnnotation { titleLabel.stringValue = KMLocalizedString("Circle") } else if subToolMode == .Rectangle { titleLabel.stringValue = KMLocalizedString("Rectangle") } else if subToolMode == .Circle { titleLabel.stringValue = KMLocalizedString("Circle") } } else if (contentViewController is KMTextBoxController) { titleLabel.stringValue = KMLocalizedString("Text Box") } else if (contentViewController is KMEditPDFTextPropertyViewController) { titleLabel.stringValue = KMLocalizedString("Text") } else if (contentViewController is KMEditImageController) { titleLabel.stringValue = KMLocalizedString("Image") } else if (contentViewController is KMLinkViewController) { titleLabel.stringValue = KMLocalizedString("Link") } else if (contentViewController is KMCropPropertyController) { titleLabel.stringValue = KMLocalizedString("Crop") } else if (contentViewController is KMStampListController) || (contentViewController is KMStampController) { titleLabel.stringValue = KMLocalizedString("Stamp") } else if (contentViewController is KMSignatureListController) || (contentViewController is KMSignatureController) { titleLabel.stringValue = KMLocalizedString("Sign") } else if (contentViewController is KMMeasureController) { titleLabel.stringValue = KMLocalizedString("Measure") } else if (contentViewController is FormsTextFieldController) { titleLabel.stringValue = KMLocalizedString("Text Field") } else if (contentViewController is FormsCheckBoxController) { titleLabel.stringValue = KMLocalizedString("Check Box") } else if (contentViewController is FormsRadioController) { titleLabel.stringValue = KMLocalizedString("Radio Button") } else if (contentViewController is FormsButtonController) { titleLabel.stringValue = KMLocalizedString("Button") } else if (contentViewController is FormsListController) { if let annotation = firstAnnotation, annotation is CPDFChoiceWidgetAnnotation { let lineAnnotation = firstAnnotation as! CPDFChoiceWidgetAnnotation if lineAnnotation.isListChoice == true { titleLabel.stringValue = KMLocalizedString("List") } else { titleLabel.stringValue = KMLocalizedString("Dropdown") } } else if subToolMode == .Form_list { titleLabel.stringValue = KMLocalizedString("List") } else if subToolMode == .Form_dropdown { titleLabel.stringValue = KMLocalizedString("Dropdown") } } else if (contentViewController is FillTickController) { titleLabel.stringValue = KMLocalizedString("Fill") } else if (contentViewController is FillDateController) { titleLabel.stringValue = KMLocalizedString("Date") } else if (contentViewController is KMOCRController) { titleLabel.stringValue = KMLocalizedString("OCR") } else if (contentViewController is FormsDigitalSignController) { titleLabel.stringValue = KMLocalizedString("Signature") } else { } } //MARK: - Setup func setupContentController() { /** Case1:选中指定模式:显示指定模式的属性设置界面,例如橡皮擦。 Case2:未选中模式:根据选中的注释显示指定属性设置界面 1、筛选出指定模式下对应的右边界面,进行显示。 2、再判断是否有选中注释,多选不同类型注释时,判断为未选中注释。 3、判断选中指定类型的注释,或者选中的模式,都展示对应的界面。 */ /** 只在指定模式下可以选中特定注释: 编辑模式下:可以选中编辑块跟Link注释 Form模式下:可以选中Form注释 */ contentViewController?.view.removeFromSuperview() contentViewController = nil let toolMode = viewManager?.toolMode ?? .None let subToolMode = viewManager?.subToolMode ?? .None let annotations: [CPDFAnnotation] = self.pdfView?.activeAnnotations as? [CPDFAnnotation] ?? [] if toolMode == .Edit { //MARK: -Edit编辑 if subToolMode == .Edit_Link { //链接 if edit_linkController == nil { edit_linkController = KMLinkViewController.init() } edit_linkController?.delegate = self edit_linkController?.pdfView = self.pdfView contentViewController = edit_linkController } else if subToolMode == .Edit_Crop { if edit_cropController == nil { edit_cropController = KMCropPropertyController.init() } contentViewController = edit_cropController } else { if pdfView?.km_EditingAreas().isEmpty == true { //未选中文字跟图片 if subToolMode == .Edit_text { if edit_textController == nil { edit_textController = KMEditPDFTextPropertyViewController.init() } edit_textController?.pdfView = self.pdfView contentViewController = edit_textController } else if subToolMode == .Edit_Image { if edit_imageController == nil { edit_imageController = KMEditImageController.init() } edit_imageController?.pdfView = self.pdfView contentViewController = edit_imageController } } else if pdfView?.km_editingImageAreas().isEmpty == true && pdfView?.km_editingTextAreas().isEmpty == false { //编辑文字 if edit_textController == nil { edit_textController = KMEditPDFTextPropertyViewController.init() } edit_textController?.pdfView = self.pdfView contentViewController = edit_textController } else if pdfView?.km_editingImageAreas().isEmpty == false && pdfView?.km_editingTextAreas().isEmpty == true { //编辑图片 if edit_imageController == nil { edit_imageController = KMEditImageController.init() } edit_imageController?.pdfView = self.pdfView contentViewController = edit_imageController } else if pdfView?.km_editingImageAreas().isEmpty == false && pdfView?.km_editingTextAreas().isEmpty == false { //混选 if edit_alignmentController == nil { edit_alignmentController = KMNAlignmentController.init() } edit_alignmentController?.delegate = self contentViewController = edit_alignmentController } } } else if toolMode == .Form { var firstAnnotation: CPDFAnnotation? if annotations.count > 0 { firstAnnotation = annotations.first } var controlType: CPDFWidgetControlType = .unknownControl var isListChoice: Int = -1 if let annotation = firstAnnotation as? CPDFButtonWidgetAnnotation { controlType = annotation.controlType() } else if let annotation = firstAnnotation as? CPDFChoiceWidgetAnnotation { isListChoice = 0 if annotation.isListChoice { isListChoice = 1 } } if firstAnnotation is CPDFTextWidgetAnnotation { if form_fieldController == nil { form_fieldController = FormsTextFieldController.init() } form_fieldController?.pdfView = self.pdfView contentViewController = form_fieldController } else if controlType == .checkBoxControl { if form_checkBoxController == nil { form_checkBoxController = FormsCheckBoxController.init() } form_checkBoxController?.pdfView = self.pdfView contentViewController = form_checkBoxController } else if controlType == .radioButtonControl { if form_radioController == nil { form_radioController = FormsRadioController.init() } form_radioController?.pdfView = self.pdfView contentViewController = form_radioController } else if isListChoice >= 0 { if form_listController == nil { form_listController = FormsListController.init() } form_listController?.pdfView = self.pdfView form_listController?.viewManager = self.viewManager contentViewController = form_listController form_listController?.clearData() } else if controlType == .pushButtonControl { if form_buttonController == nil { form_buttonController = FormsButtonController.init() } form_buttonController?.pdfView = self.pdfView contentViewController = form_buttonController } else if firstAnnotation is CPDFSignatureWidgetAnnotation { if form_digitalSignController == nil { form_digitalSignController = FormsDigitalSignController.init() } form_digitalSignController?.pdfView = self.pdfView contentViewController = form_digitalSignController } } else { let exitMulitAnnotation = pdfView?.isMultiAnnotation(annotations) if exitMulitAnnotation == true { return } var firstAnnotation: CPDFAnnotation? if annotations.count > 0 { firstAnnotation = annotations.first } if viewManager?.viewToolsType == .Content_Selection { if edit_cropController == nil { edit_cropController = KMCropPropertyController.init() } contentViewController = edit_cropController } else if firstAnnotation is CPDFMarkupAnnotation || subToolMode == .Highlight || subToolMode == .Underline || subToolMode == .Waveline || subToolMode == .Strikethrough { if highlight_Controller == nil { highlight_Controller = KMHighlightController.init() } highlight_Controller?.pdfView = self.pdfView contentViewController = highlight_Controller } else if firstAnnotation is CPDFFreeTextAnnotation || subToolMode == .Text || subToolMode == .fill_date { if firstAnnotation is CSelfSignAnnotationFreeText || subToolMode == .fill_date { if fill_dateController == nil { fill_dateController = FillDateController.init() } fill_dateController?.pdfView = self.pdfView contentViewController = fill_dateController } else { if freeText_Controller == nil { freeText_Controller = KMTextBoxController.init() } freeText_Controller?.pdfView = self.pdfView contentViewController = freeText_Controller } } else if firstAnnotation is CPDFTextAnnotation || subToolMode == .Note { if note_Controller == nil { note_Controller = KMNoteController.init() } note_Controller?.pdfView = self.pdfView contentViewController = note_Controller } else if firstAnnotation is CPDFInkAnnotation || subToolMode == .Pen { if pen_Controller == nil { pen_Controller = KMPenController.init() } pen_Controller?.pdfView = self.pdfView contentViewController = pen_Controller } else if subToolMode == .Eraser { if eraser_Controller == nil { eraser_Controller = KMEraserController.init() } contentViewController = eraser_Controller } else if firstAnnotation is CPDFCircleAnnotation || firstAnnotation is CPDFSquareAnnotation || subToolMode == .Rectangle || subToolMode == .Circle { if rectangle_Controller == nil { rectangle_Controller = KMRectangleController.init() } rectangle_Controller?.pdfView = self.pdfView contentViewController = rectangle_Controller } else if firstAnnotation is CPDFLineAnnotation || firstAnnotation is CPDFPolylineAnnotation || firstAnnotation is CPDFPolygonAnnotation || subToolMode == .Line || subToolMode == .Arrow || subToolMode == .Measure { var isMeasure = false if let annotation = firstAnnotation as? CPDFLineAnnotation, annotation.isMeasure == true { isMeasure = true } else if let _ = firstAnnotation as? CPDFPolylineAnnotation { isMeasure = true } else if let _ = firstAnnotation as? CPDFPolygonAnnotation { isMeasure = true } else if subToolMode == .Measure { isMeasure = true } if isMeasure { if measure_Controller == nil { measure_Controller = KMMeasureController.init() } measure_Controller?.pdfView = self.pdfView measure_Controller?.viewManager = self.viewManager contentViewController = measure_Controller } else { if line_Controller == nil { line_Controller = KMLineController.init() } line_Controller?.pdfView = self.pdfView contentViewController = line_Controller } } else if firstAnnotation is CPDFStampAnnotation { if firstAnnotation is CSelfSignAnnotation { if fill_tickController == nil { fill_tickController = FillTickController.init() } fill_tickController?.viewManager = self.viewManager fill_tickController?.pdfView = self.pdfView contentViewController = fill_tickController } else { if stamp_Controller == nil { stamp_Controller = KMStampController.init() } stamp_Controller?.pdfView = self.pdfView stamp_Controller?.delegate = self contentViewController = stamp_Controller } } else if subToolMode == .Stamp { if stamplist_Controller == nil { stamplist_Controller = KMStampListController.init() stamplist_Controller?.delegate = self } stamplist_Controller?.pdfView = self.pdfView contentViewController = stamplist_Controller } else if firstAnnotation is CPDFSignatureAnnotation { if signature_Controller == nil { signature_Controller = KMSignatureController.init() } signature_Controller?.pdfView = self.pdfView contentViewController = signature_Controller } else if subToolMode == .Sign || subToolMode == .fill_sign { if signatureList_Controller == nil { signatureList_Controller = KMSignatureListController.init() } signatureList_Controller?.pdfView = self.pdfView contentViewController = signatureList_Controller } else if subToolMode == .Fill_tick || subToolMode == .fill_fork || subToolMode == .fill_rectangle || subToolMode == .fill_line || subToolMode == .fill_dot { if fill_tickController == nil { fill_tickController = FillTickController.init() } fill_tickController?.viewManager = self.viewManager fill_tickController?.pdfView = self.pdfView contentViewController = fill_tickController } else if subToolMode == .Measure { if measure_Controller == nil { measure_Controller = KMMeasureController.init() } measure_Controller?.pdfView = self.pdfView measure_Controller?.viewManager = self.viewManager contentViewController = measure_Controller } else if subToolMode == .Tool_OCR { if tool_OCRController == nil { tool_OCRController = KMOCRController.init() tool_OCRController?.typeChange = { [unowned self] controller, type in delegate?.kmRightSideControllerOCRShowTypeChange(self, type) } tool_OCRController?.doneAction = { [unowned self] controller, model in delegate?.kmRightSideControllerOCRDoneAction(self, model) } } tool_OCRController?.pdfView = self.pdfView contentViewController = tool_OCRController } else { } } if let contendVC = contentViewController { contendVC.view.frame = infoContendView.bounds contendVC.view.autoresizingMask = [.width, .height] // infoContendView.addSubview(contendVC.view) // infoScrollView.contentViewSize = CGSizeMake(264, 600) infoScrollView.documentView = contendVC.view // infoScrollView.layout() delegate?.kmRightSideControllerDidContendVCUpdated?(self) } if let _ = contentViewController { infoContendView.isHidden = false headerBGView.isHidden = false emptyView.isHidden = true } else { infoContendView.isHidden = true headerBGView.isHidden = true emptyView.isHidden = false } updateTitleLabel() } //MARK: - reloadData func reloadContendTopConst() { infoContendTopConst.constant = 40 headerBGView.isHidden = false if contentViewController is KMHighlightController { //高亮 if CPDFMarkupAnnotation.isMarkupAnnotationsContainMultiType((contentViewController as! KMHighlightController).getValidAnnotations()) { infoContendTopConst.constant = 0 headerBGView.isHidden = true } } else if contentViewController is KMLineController { //线段 if CPDFLineAnnotation.isLineAnnotationsContainMultiType((contentViewController as! KMLineController).getValidAnnotations()) { infoContendTopConst.constant = 0 headerBGView.isHidden = true } } else if contentViewController is KMRectangleController { //图形 let annotations: [CPDFAnnotation] = self.pdfView?.activeAnnotations as? [CPDFAnnotation] ?? [] if CPDFAnnotation.isShapeAnnotationsContainMultiType(annotations) { infoContendTopConst.constant = 0 headerBGView.isHidden = true } } else if contentViewController is KMNAlignmentController { //对齐 infoContendTopConst.constant = 0 headerBGView.isHidden = true } } func reloadTopRightButtonInfo() { headerRightButton.isHidden = true if contentViewController is KMStampListController { let stampListVC = contentViewController as! KMStampListController if stampListVC.stampType == .dynamic { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "stampDynamic_Setting"), keepPressState: false) } else if stampListVC.stampType == .custom { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "watermark_template_add"), keepPressState: false) } } else if contentViewController is KMSignatureListController { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "watermark_template_add"), keepPressState: false) } else if contentViewController is KMOCRController { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "tools_report"), keepPressState: false) headerRightButton.toolTip = KMLocalizedString("If you have any feedback or suggestions for improvements to the OCR feature, please contact us.") } else if contentViewController is KMMeasureController { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "stampDynamic_Setting"), keepPressState: false) } else if contentViewController is KMCropPropertyController { headerRightButton.isHidden = false headerRightButton.properties = ComponentButtonProperty(type: .text_gray, size: .xxs, onlyIcon: true, icon: NSImage(named: "icon_recover"), keepPressState: false) } headerRightButton.setTarget(self, action: #selector(headerRightButtonClicked(_:))) } func reloadData() { let toolMode = viewManager?.toolMode ?? .None let subToolMode = viewManager?.subToolMode ?? .None if (contentViewController is KMHighlightController) { (contentViewController as? KMHighlightController)?.viewManager = viewManager (contentViewController as? KMHighlightController)?.reloadData() } else if (contentViewController is KMNoteController) { (contentViewController as? KMNoteController)?.reloadData() } else if (contentViewController is KMPenController) { (contentViewController as? KMPenController)?.reloadData() } else if (contentViewController is KMEraserController) { (contentViewController as? KMEraserController)?.reloadData() } else if (contentViewController is KMLineController) { (contentViewController as? KMLineController)?.viewManager = viewManager (contentViewController as? KMLineController)?.reloadData() } else if (contentViewController is KMRectangleController) { (contentViewController as? KMRectangleController)?.viewManager = viewManager (contentViewController as? KMRectangleController)?.reloadData() } else if (contentViewController is KMTextBoxController) { (contentViewController as? KMTextBoxController)?.reloadData() } else if (contentViewController is KMStampController) { (contentViewController as? KMStampController)?.reloadData() } else if (contentViewController is KMSignatureListController) { (contentViewController as? KMSignatureListController)?.reloadData() } else if (contentViewController is FormsTextFieldController) { (contentViewController as? FormsTextFieldController)?.reloadData() } else if (contentViewController is FormsCheckBoxController) { (contentViewController as? FormsCheckBoxController)?.reloadData() } else if (contentViewController is FormsRadioController) { (contentViewController as? FormsRadioController)?.reloadData() } else if (contentViewController is FormsListController) { (contentViewController as? FormsListController)?.reloadData() } else if (contentViewController is FormsButtonController) { (contentViewController as? FormsButtonController)?.reloadData() } else if (contentViewController is FormsDigitalSignController) { (contentViewController as? FormsDigitalSignController)?.reloadData() } else if (contentViewController is FillTickController) { (contentViewController as? FillTickController)?.reloadData() } else if (contentViewController is FillDateController) { (contentViewController as? FillDateController)?.reloadData() } else if (contentViewController is KMMeasureController) { (contentViewController as? KMMeasureController)?.reloadData() } else if (contentViewController is KMSignatureController) { (contentViewController as? KMSignatureController)?.reloadData() } else if (contentViewController is KMEditPDFTextPropertyViewController) { (contentViewController as? KMEditPDFTextPropertyViewController)?.reloadData() } else if (contentViewController is KMEditImageController) { (contentViewController as? KMEditImageController)?.reloadData() } else if (contentViewController is KMLinkViewController) { (contentViewController as? KMLinkViewController)?.reloadData() } else if (contentViewController is KMCropPropertyController) { (contentViewController as? KMCropPropertyController)?.reloadData() } else if (contentViewController is KMNAlignmentController) { if let areas = pdfView?.km_EditingAreas(), areas.count > 2 { (contentViewController as? KMNAlignmentController)?.updateMulti(true) } else { (contentViewController as? KMNAlignmentController)?.updateMulti(false) } } if toolMode == .Markup { if (subToolMode == .Highlight || subToolMode == .Underline || subToolMode == .Waveline || subToolMode == .Strikethrough) && (contentViewController is KMHighlightController) { (contentViewController as? KMHighlightController)?.reloadData() } } reloadContendTopConst() reloadTopRightButtonInfo() } public func reloadDataWithPDFView(pdfView: CPDFListView) { self.pdfView = pdfView setupContentController() reloadData() } //MARK: - Action @objc func headerRightButtonClicked(_ button: ComponentButton) { if contentViewController is KMStampListController { let stampListVC = contentViewController as! KMStampListController if stampListVC.stampType == .dynamic { stampListVC.showDynamicSetting() } else if stampListVC.stampType == .custom { stampListVC.createCustomStamp() } } else if contentViewController is KMSignatureListController { let vc = contentViewController as! KMSignatureListController vc.createCustomStamp() } else if contentViewController is KMMeasureController { delegate?.kmRightSideControllerShowMeasureSetting(self) } else if contentViewController is KMCropPropertyController { } else if contentViewController is KMOCRController { let help = KMUserFeekbackHanddler() help.showFeekbackWindow(with: KMLocalizedString("Propose a New Feature", comment: "")) } } //MARK: - 重新刷新编辑中内容 public func reloadEditingAreas() { if contentViewController is KMEditPDFTextPropertyViewController { (contentViewController as! KMEditPDFTextPropertyViewController).reloadData() } else if contentViewController is KMEditImageController { (contentViewController as! KMEditImageController).reloadData() } } //MARK: - 裁剪模式下刷新文档 public func reloadCropDocument(_ pdfview: CPDFListView?) { if viewManager?.subToolMode == .Edit_Crop && (contentViewController is KMCropPropertyController) { (contentViewController as! KMCropPropertyController).pdfView = pdfview (contentViewController as! KMCropPropertyController).reloadData() } } } //MARK: - KMStampListControllerDelegate extension KMRightSideController: KMStampListControllerDelegate { func kmStampListControllerDidStampTypeUpdated(_ controller: KMStampListController) { reloadTopRightButtonInfo() } } //MARK: - KMStampControllerDelegate extension KMRightSideController: KMStampControllerDelegate { func kmStampControllerRotateLeft(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) { delegate?.kmRightSideControllerRotateLeft(annotations, withPDFView: pdfView) } func kmStampControllerRotateRight(_ annotations: [CPDFStampAnnotation], withPDFView pdfView: CPDFListView?) { delegate?.kmRightSideControllerRotateRight(annotations, withPDFView: pdfView) } } //MARK: - KMLinkViewControllerDelegate extension KMRightSideController: KMLinkViewControllerDelegate { func kmLinkViewControllerDidUpdateMode(_ controller: KMLinkViewController) { delegate?.kmRightSideControllerDidContendVCUpdated?(self) } } //MARK: - KMNAlignmentControllerDelegate extension KMRightSideController: KMNAlignmentControllerDelegate { func alignmentControllerDidClick(_ controller: KMNAlignmentController, _ alignmentType: KMPDFActiveFormsAlignType) { pdfView?.changeEditingAreas(alignmentType) } }